← Quiz: String Handling in C: all 15 questions
Quiz: String Handling in C · Question 1 of 15
What does this print? (code)
What does this print?
#include <stdio.h>
int len(const char *s) {
const char *p = s;
while (*p) p++;
return (int)(p - s);
}
int main(void) {
printf("%d", len("Skills101"));
return 0;
}
- A.8
- B.9
- C.10
- D.0
Answer & explanation
Correct answer: 9
p stops at the '\0' after "Skills101", which is 9 characters from the start.
Can you get the rest right without peeking?
Take the timed Quiz: String Handling in C quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →