ProgrammingModerate
char name[] = "Bob"; char *p = name; printf("%c%c", p[0], *(p + 2)); What is printed?
- A. Bo
- B. Ob
- C. Bb
- D. Bob
Correct answer: C. Bb
p[0] is B and *(p + 2) is the last letter b, so the output is Bb.
More C Programming questions
- char buf[] = "ab"; buf[2] = 'c'; printf("%zu", sizeof buf); What is printed?
- char s[3] = "ab"; printf("%zu", sizeof s); What is printed?
- char a = "xy"; char b = a; b[0] = 'z'; printf("%s", a); What is printed?
- char buf[8] = "12"; int n = strlen(buf); printf("%d %d", n, (int)sizeof buf - n); What is printed?
- char z[6] = "ab0cd"; printf("%zu", strlen(z)); What is printed?
- int n = sprintf(NULL, "%s", "hello"); printf("%d", n); What is printed?