ProgrammingModerateTCS NQT · Infosys
What is printed? Assume int is 4 bytes.
What is printed? Assume int is 4 bytes.
#include <stdio.h>
int main(void) {
int m[4][5];
printf("%zu %zu", sizeof m / sizeof m[0], sizeof m[0] / sizeof m[0][0]);
}- A. 20 5
- B. 5 4
- C. 4 20
- D. 4 5
Correct answer: D. 4 5
sizeof m / sizeof m[0] counts the rows, which is 4, and sizeof m[0] / sizeof m[0][0] counts the columns, which is 5.
More C Programming questions
- What is printed? Assume unsigned int is 32 bits. c #include <stdio.h> int main(void) { unsigned s = 0; for (unsigned i = 1; i <= 100000…
- How many partitions of 5 are there? The program counts partitions of n into parts of size at most m. Compute with it. c #include <stdio.h>…
- What is printed? c #include <stdio.h> int main(void) { char c = 'A'; c += 32; printf("%c %d", c, c); }
- What is printed? c #include <stdio.h> int main(void) { int x = 2, r = 0; switch (x) { case 1: r += 1; case 2: r += 10; case 3: r += 100…
- How many loop iterations run? Compute with the program. c #include <stdio.h> int main(void) { unsigned x = 0xF00D; int c = 0; while (x) {…
- What is printed? c #include <stdio.h> int main(void) { int i = 5; do { i++; } while (i < 3); printf("%d", i); }