ProgrammingModerateGATE CS · Campus placements
What does printf("%d", '7' - '0' == 7) print?
- A. 7
- B. 1
- C. 0
- D. compile error
Correct answer: B. 1
The digit characters are contiguous in every conforming character set, so '7' - '0' is 7 and the comparison is true, printing 1.
More C Programming questions
- Reversing the list 1 -> 2 -> 3 -> 4 -> 5 in place with the usual three-pointer loop, what are head->v and head->next->v afterwards?
- In a list 1 -> 2 -> 3 -> 4 -> 2 where the last node points back to the node holding 2, Floyd's method runs slow = slow->next and fast =…
- A pointer-to-pointer loop deletes every node holding 2 from 2 -> 2 -> 3 -> 2 -> 1, using struct N pp = &head and advancing only when no…
- Which code correctly removes node p from a doubly linked list, where p->prev and p->next may be NULL, and then frees it?
- Merging two sorted singly linked lists of length 3 each with the standard merge, what is the largest number of key comparisons needed?
- With a 4-byte int and an 8-byte pointer, natural alignment, what is sizeof(struct N) for struct N { int v; struct N next; };?