ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
#include <stdio.h>
#include <string.h>
int main(void) {
printf("%d", strcmp("apple", "apricot") < 0);
}- A. 0
- B. 2
- C. 3
- D. 1
Correct answer: D. 1
apple and apricot share the prefix ap, then p (112) is less than r (114), so apple sorts first and the comparison is true.
More C Programming questions
- How many times does the letter a occur in "panda"? The program counts with recursion. c #include <stdio.h> int cnt(const char s) { if (s…
- What is printed by this recursive Pascal triangle entry? c #include <stdio.h> int C(int n, int k) { if (k == 0 || k == n) return 1; return…
- What is printed? c #include <stdio.h> int main(void) { int c = 0; for (int i = 0; i < 5; i++) { switch (i) { case 2: break; default: c++…
- What is printed? c #include <stdio.h> int main(void) { int c = 0; for (int i = 0; i < 5; i++) { switch (i) { case 1: continue; } c++; }…
- What is printed? c #include <stdio.h> int main(void) { int m[2][3] = {{1, 2, 3}, {4, 5, 6}}; printf("%d", ((m + 1) + 2)); }
- What is printed? c #include <stdio.h> int f(void) { static int a[3]; a[0]++; return a[0]; } int main(void) { int x = f(); int y = f(); int…