ProgrammingModerateWipro · Capgemini pattern
What is printed?
What is printed?
char s[20] = "Code";
strcat(s, "Hub");
printf("%zu", strlen(s));- A. 20
- B. 4
- C. 7
- D. 8
Correct answer: C. 7
strcat appends "Hub" after "Code", giving "CodeHub" with 7 characters. strlen ignores the '\0' and the unused space of the 20-byte array.
More C Programming questions
- What is printed on a two's-complement machine? c printf("%d", ~5);
- What is printed by a C99 (or later) compiler? c printf("%d %d", -7 / 2, -7 % 2);
- What is printed? c char s = "Campus"; printf("%c%s", (s + 1), s + 4);
- What is printed? c printf("%d", printf("hello"));
- On a 64-bit system (8-byte pointers, 4-byte int), what does f print? c void f(int a[10]) { printf("%zu", sizeof(a)); }
- How many times is fib called in total (including the first call) when evaluating fib(5)? c int fib(int n) { if (n <= 1) return n; return…