ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
#include <stdio.h>
#include <string.h>
int main(void) {
char *w[] = {"ab", "cde"};
char **p = w;
printf("%d", (int)strlen(p[1]) * (int)strlen(*p));
}- A. 6
- B. 5
- C. 9
- D. 2
Correct answer: A. 6
p[1] is "cde" with length 3, and *p is "ab" with length 2, so the product is 6.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { int a[5] = {0}; int p = a + 4; printf("%ld", (long)(p - &a[0])); }
- What is printed? c #include <stdio.h> int main(void) { int a[] = {1, 3, 2, 5}, c = 0; for (int p = a; p < a + 4; p++) if (p > 2) c++…
- What is printed? c #include <stdio.h> int main(void) { int x = 0, p = &x; p++ = 5; printf("%d", x); }
- What is printed? c #include <stdio.h> int main(void) { const char s = "abc"; printf("%d", s[3] == '0'); }
- What is printed? c #include <stdio.h> int main(void) { int v[] = {-1, -2, -3}; unsigned s = 0; for (int i = 0; i < 3; i++) s +=…
- How many zero bits are there in the low eight bits of 0xF0? Count them with this program. c #include <stdio.h> int main(void) { unsigned x…