- Executors
-
Learn
Learn Python Runnable examples, NumPy, pandas, and more Learn AI / Machine LearningNeural networks, ML and LLMs from scratch Learn C & C++ Pointers, memory, STL, and modern C++ Learn C#C# basics, OOP, LINQ, async, and .NET exercises Learn MatplotlibLine, bar, scatter and pie charts with live visualizers Learn RustOwnership, traits, error handling, and threads Learn GoSlices, interfaces, goroutines, and channels Python Algorithms Search, sorting, recursion, and visualizers O(n) C & C++ Algorithms Compare algorithms implemented in C and C++ Coding for Kids Learn to code by playing!
- QuizzesNew
- ChallengesNew
- For TeachersNew
- Updates
- Buy me a coffee
C Structs & typedef Quiz
Structs are how C groups related values into one type. This easy quiz covers declaring and initialising structs, copying them, nesting them, the -> operator and typedef, with a look at why struct sizes can surprise you.
Sample question
Question 1 of 10What does this print?
#include <stdio.h>
struct point {
int x;
int y;
};
int main(void) {
struct point p = {3, 7};
printf("%d %d\n", p.x, p.y);
return 0;
}
Show the answer
A. 3 7 A brace initializer fills the members in the order they are declared, so x gets 3 and y gets 7.
What this quiz covers
- Declaring structs and initialising them, including designated initializers
- Struct assignment copies every member
- Nested structs and the
->operator typedeffor shorter type names- Padding and why you cannot compare structs with
==
Questions people ask
Do I need an account?
No. Anyone can play. Sign in to keep your XP, streak, badges and history.
Can I retake it?
Yes. Your best score is kept, and the questions and answers are shuffled each time.