ProgrammingModerate
char c = 'A'; printf("%d %c", c + 1, c + 1); What is printed?
- A. 66 B
- B. 65 A
- C. 66 66
- D. B B
Correct answer: A. 66 B
c + 1 is the int 66, which prints as 66, and %c prints the same value as the character B.
More C Programming questions
- printf("%s", "abc" + 1); What is printed?
- char name[] = "Bob"; char p = name; printf("%c%c", p[0], (p + 2)); What is printed?
- 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?