ProgrammingVery hard
char s[] = "abc"; printf("%c", s[sizeof s - 1]); What is printed?
- A. \0 (prints nothing visible)
- B. c
- C. b
- D. d
Correct answer: A. \0 (prints nothing visible)
sizeof s is 4, so the index 3 is the terminator. Printing it with %c emits a NUL byte, which is not a visible character.
More C Programming questions
- printf("%d", (int)sizeof(char)); What is printed in C?
- char w[] = "one two"; char p = w; while (p && p != ' ') p++; printf("%d", (int)(p - w)); What is printed?
- char s[] = "aXbXc"; int x = 0; for (int i = 0; s[i]; i++) x += s[i] == 'X'; printf("%d", x); What is printed?
- printf("%s", strcat(strcpy(buf, "ab"), "cd")); with char buf[10] declared before the call. What is printed?
- Records are sorted by name length first, then alphabetically, using qsort with a comparator on strlen and strcmp. Input names: bob, al…
- Records (x,5), (y,2), (z,5), (w,2), (v,9) are sorted by key with a stable sort, ascending. What is the order of names?