ProgrammingHard
char s[5] = "abc"; printf("%d", s[4]); What is printed?
- A. 0
- B. 97
- C. 99
- D. 32
Correct answer: A. 0
The array has room for five characters, and the unused tail is zero, so s[4] is 0.
More C Programming questions
- printf("%zu", strlen("a b c")); What is printed?
- char buf[16]; sprintf(buf, "%d-%d", 1, 22); printf("%zu", strlen(buf)); What is printed?
- char s[] = "abcd"; int n = strlen(s); for (int i = 0; i < n / 2; i++) { char t = s[i]; s[i] = s[n - 1 - i]; s[n - 1 - i] = t; }…
- char s[] = "a1B2-c"; int n = 0; for (char p = s; p; p++) if (isalpha((unsigned char)p)) n++; printf("%d", n); What is printed?
- char c = 'a' + 1; printf("%c", c); What is printed?
- printf("%5.3s|", "abcdef"); What is printed?