🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Structures and Unions: all 10 questions

Quiz: Structures and Unions · Question 8 of 10

What does this print? (code)

What does this print?

#include <stdio.h>
struct S { char name[10]; int marks; };
int main(void) {
    struct S c[3] = {{"Asha", 70}, {"Ravi", 85}, {"Om", 60}};
    struct S *p = c;
    p++;
    printf("%s %d\n", p->name, (p + 1)->marks);
    return 0;
}
  1. A.Asha 85
  2. B.Ravi 60
  3. C.Ravi 85
  4. D.Om 60
Answer & explanation

Correct answer: Ravi 60

p++ moves to the next whole struct (Ravi); p + 1 is the one after it (Om, 60).

Can you get the rest right without peeking?

Take the timed Quiz: Structures and Unions quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →