ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
int c = 0;
switch ('b') {
case 'a': c++;
case 'b': c += 10;
case 'c': c += 100; break;
}
printf("%d", c);
}- A. 10
- B. 100
- C. 11
- D. 110
Correct answer: D. 110
Entry at case 'b' falls through into case 'c' before the break, so 10 + 100 = 110.
More C Programming questions
- How many nodes are at depth 2 in a perfect binary tree of depth 3 (the root is depth 0)? The program counts them recursively. c #include…
- What is printed? Each struct has an int a and an int b. c #include <stdio.h> #include <stdlib.h> struct P { int a, b; }; int cmp(const…
- What is printed? c #include <stdio.h> int main(void) { unsigned x = 11, y = x & (x + 1); printf("%u", y); }
- What is printed? Assume int is 4 bytes. c #include <stdio.h> int main(void) { int (p)[3] = 0; printf("%zu", sizeof p); }
- What is printed? Assume the array has space for 5 characters. c #include <stdio.h> int main(void) { char s[5] = "abcd"; printf("%zu"…
- What is printed? c #include <stdio.h> int main(void) { printf("%d", 'A' == 65); }