ProgrammingModerateWipro · Capgemini pattern
What is printed?
What is printed?
char *names[] = {"Ann", "Bob", "Cy"};
printf("%c %s %zu", names[1][0], names[2], strlen(names[0]));- A. A Cy 3
- B. B Cy 3
- C. B Bob 3
- D. B Cy 4
Correct answer: B. B Cy 3
names is an array of three char pointers. names[1][0] is the first character of "Bob"; names[2] is "Cy"; strlen("Ann") is 3 (the terminator is not counted).
More C Programming questions
- What is printed? c int n = 40; / binary 101000 / printf("%d %d %d", n & (n - 1), n & -n, (n & (n - 1)) == 0);
- What is printed? c int a[] = {3, 1, 4, 1, 5}; int sum(int n) { return n == 0 ? 0 : a[n - 1] + sum(n - 1); } int main(void) { printf("%d"…
- Assume a 64-bit LP64 ABI (4-byte int, 8-byte pointers and double, natural alignment). What is printed? c int a[3][4] = {{1, 2, 3, 4}, {5…
- Assume 32-bit int and two's complement. What is printed? c unsigned char a = 0x0F; unsigned char b = ~a; printf("%d %d %d %d %zu", ~a ==…
- Assume 32-bit int and 64-bit long long. What is printed? c int n = -1; unsigned int len = 3; long long big = -1; printf("%d %d %d %d", n <…
- Assume a 64-bit LP64 ABI (4-byte int, 8-byte pointers and double, natural alignment). What is printed? c struct A { char c; double d; int…