← 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;
}
- A.Asha 85
- B.Ravi 60
- C.Ravi 85
- 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 →