ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
char g[3][4] = {"abc", "def", "ghi"};
for (int j = 0; j < 3; j++) putchar(g[2 - j][j]);- A. gec
- B. ceg
- C. aei
- D. ieg
Correct answer: A. gec
The row runs 2, 1, 0 while the column runs 0, 1, 2, tracing the anti-diagonal from bottom left: g[2][0] = 'g', g[1][1] = 'e', g[0][2] = 'c'. 'aei' is the main diagonal.
More C Programming questions
- A file report.txt already exists and holds data. What does fopen("report.txt", "w") do?
- The user types hello and presses Enter. After char buf[8]; fgets(buf, sizeof buf, stdin);, what does buf hold?
- The user types abcdefghij and presses Enter. What is strlen(buf) after char buf[8]; fgets(buf, sizeof buf, stdin);?
- After scanf("%d", &n); reads the input 42 followed by Enter, why does the next getchar() return 'n' instead of waiting for new input?
- What is printed? c int buf[4], head = 0, count = 0; for (int v = 1; v <= 6; v++) { buf[(head + count) % 4] = v; if (count < 4) count++…
- What is printed? c int st[10], top = -1; #define PUSH(x) (st[++top] = (x)) #define POP() (st[top--]) int main(void) { PUSH(3); PUSH(5)…