- 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
Output-Based C Questions
Many C interviews start with "what does this print?". This quiz gives you short, complete C programs that test post-decrement loops, chained and compound assignments, nested ternaries, the comma operator and logical operators, so you can practise reading code the way the compiler does.
Sample question
Question 1 of 10What does this print?
#include <stdio.h>
int main(void) {
int n = 3;
while (n--) {
printf("%d ", n);
}
printf("| %d\n", n);
return 0;
}
Show the answer
B. 2 1 0 | -1 n-- tests the old value and then decrements, so the body sees 2, 1 and 0. The final test reads 0 (false) but still decrements, leaving n at -1.
What this quiz covers
while (n--)and where the counter ends upbreakin nested loops- Chained and compound assignment
- Nested
?:and the comma operator infor - Logical operators always give 0 or 1
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.