ProgrammingModerateTCS NQT · Wipro
What is printed?
What is printed?
#include <stdio.h>
void rev(const char *s) {
if (*s == '\0') return;
rev(s + 1);
putchar(*s);
}
int main(void) {
rev("stack");
}- A. stack
- B. kcast
- C. kcats
- D. ktsca
Correct answer: C. kcats
The recursion prints the rest of the string before the current character, so each character appears in reverse order. The output is kcats.
More C Programming questions
- What is printed? c #include <stdio.h> int calls = 0; int A(int m, int n) { calls++; if (m == 0) return n + 1; if (n == 0) return A(m - 1…
- What is printed? c #include <stdio.h> int main(void) { unsigned x = 0x16D; printf("%u", x & 0xF); }
- What is printed? Assume unsigned int is 32 bits. c #include <stdio.h> int main(void) { unsigned x = 32, b1 = (x >> 1) & 1u, b5 = (x >> 5)…
- What is printed? c #include <stdio.h> int main(void) { unsigned a = 0xC, b = 0xA, c = 0x9; unsigned m = (a & b) | (b & c) | (a & c)…
- What is printed? c #include <stdio.h> int main(void) { int a[] = {1, 4, 6}, b[] = {2, 3, 8, 9}; int m[7], i = 0, j = 0, k = 0; while (i <…
- What is printed? c #include <stdio.h> int main(void) { int a[] = {3, 9, 2, 9, 1}, n = 5; int mx = a; for (int p = a + 1; p < a + n; p++)…