How to use the C Programming Practice Problems
- 1. Pick a problemFilter by level and choose a problem. Its task and sample tests appear below.
- 2. Write and run it locallyWrite your C solution here (it's saved in this browser), then run it with gcc on each sample input.
- 3. Check your outputPaste what your program printed for each test and press Check. Solved problems get a tick.
What's in the set
The 20 problems cover what C exams and fresher interviews ask most: digit problems (sum of digits, reversing a number, Armstrong numbers), primes, Fibonacci and factorial with the right integer types, arrays (largest and smallest, reversing in place, second largest, binary search, bubble sort), strings (vowels, palindromes, length without strlen, character frequency), pointers (swapping through int *), and 2-D arrays (transpose and matrix multiplication).
Every reference solution was compiled with gcc using -Wall -Wextra -Werror and run against all of its sample tests before publishing.
Worked example: second largest element
For the input 5 and 10 20 4 45 99, the expected output is 45. The trap is duplicates: for 3 and 5 9 9 the answer is 5, not 9, and if every value is the same the program must print -1. The hint shows the one-pass method: keep first and second; when a value beats first, the old first becomes second.
If your program prints 45 with a trailing space, the checker still accepts it, because spaces at the ends of lines are ignored. A missing line or a different number is reported with the position of the first difference.
Why this page doesn't run C
Compiling C in the browser would need a large WebAssembly compiler download, and sending your code to a server would mean uploading it. Instead, you run it with gcc on your own computer or any compiler you already use, and this page checks the output. It's the same skill online judges test: exact output for given input.
Frequently asked questions
Which compiler should I use?
Any C11 compiler: gcc, clang or MinGW on Windows. Compile with warnings on, like gcc -Wall main.c.
How do I feed the sample input?
Type it in when the program waits, or save it to input.txt and run ./main < input.txt.
Is my code uploaded?
No. Your code and outputs stay in your browser.
Is the C practice problems free?
Yes. Everything in the C practice problems works without signing up. The first time you ask for a result, we ask once for your name and WhatsApp number; after that the C practice problems and every other Uncodemy tool open straight away.