🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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;
}
  1. A.8
  2. B.9
  3. C.10
  4. 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 →