← Quiz: C Arrays and Strings: all 10 questions
Quiz: C Arrays and Strings · Question 7 of 10
What does this print? (code)
What does this print?
#include <stdio.h>
#include <string.h>
int main(void) {
char s[20] = "Hi";
strcat(s, " there");
printf("%s %zu\n", s, strlen(s));
return 0;
}
- A.Hi there 20
- B.Hi 2
- C.Hi there 8
- D.Hi there 9
Answer & explanation
Correct answer: Hi there 8
strcat appends " there" (6 characters) to "Hi" (2), giving 8 characters; strlen does not count '\0'.
Can you get the rest right without peeking?
Take the timed Quiz: C Arrays and Strings quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →