ProgrammingModerate
char s[] = "a\tb"; printf("%zu", strlen(s)); What is printed?
- A. 4
- B. 2
- C. 3
- D. 5
Correct answer: C. 3
The tab is a single character, so the string holds a, tab and b, which is three characters.
More C Programming questions
- char s[] = "x0y"; printf("%s", s); What is printed?
- char s[5] = "abc"; printf("%d", s[4]); What is printed?
- 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?