ProgrammingModerateAccenture · Cognizant pattern
What is printed?
What is printed?
char s[] = "placement";
printf("%zu %zu", sizeof(s), strlen(s));- A. 10 9
- B. 9 9
- C. 10 10
- D. 9 10
Correct answer: A. 10 9
The array holds 9 letters plus the terminating '\0', so sizeof(s) = 10. strlen counts characters before the '\0', giving 9.
More C Programming questions
- What is printed? c int arr[] = {10, 20, 30, 40}; int p = arr; p += 2; printf("%d", p);
- What does f(4096) return? c int f(int n) { if (n == 0) return 0; return n % 10 + f(n / 10); }
- What is printed? c printf("%d %d %d", 12 & 10, 12 | 10, 12 ^ 10);
- What is printed? c #define SQUARE(x) x x printf("%d", SQUARE(2 + 3));
- What is printed when count() is called three times in a row? c void count(void) { static int c = 0; c++; printf("%d ", c); }
- What is printed? c int a[5] = {1, 2}; printf("%d", a[3]);