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));
}
  1. A. 6
  2. B. 5
  3. C. 9
  4. 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

Exams that ask this topic