ProgrammingVery hardTCS NQT · Infosys
What does printf("%d", strcmp("apple", "Apple") > 0) print?
- A. true (1)
- B. false (0)
- C. 0
- D. -1
Correct answer: A. true (1)
The C standard compares strings as unsigned char, and 'a' (97) is greater than 'A' (65). So strcmp returns a positive value and the comparison is true.
More C Programming questions
- A stair can be climbed by 1, 2 or 3 steps. How many ways are there to climb 4 stairs?
- #define N 3 and int a[N 2 + 1]; What is sizeof a / sizeof a[0]?
- int x = 5, y = 3; What does printf("%d", x & y | 4 ^ 1) print?
- unsigned int n = 3u; int k = -1; if (k > n) printf("yes"); else printf("no"); What is printed?
- Which type reliably holds the sum 1 + 2 + ... + 100000 = 5000050000?
- What is (uint32t)~0u >> 28?