A comprehensive collection of 350+ C programming exercises designed to solidify fundamental concepts through hands-on practice.
Perfect for beginners and anyone looking to master C programming from basics to advanced pointers!
Welcome to Ultimate C Exercises! This repository is your go-to resource for learning and practicing the C programming language. Whether you're a complete beginner or looking to refresh your skills, you'll find carefully structured exercises that progressively build your understanding of core C concepts.
This collection covers everything from basic syntax to pointers, providing hands-on practice for each fundamental pillar of C programming.
- Structured Learning Path — Exercises organized by topic with progressive difficulty levels
- Beginner-Friendly — Clear explanations and examples to help you get started
- Comprehensive Coverage — Topics range from basics to pointers and data structures
- Hands-on Practice — Learn by doing with real coding challenges
- Well-Organized — Easy to navigate through different programming concepts
- Extensive Exercises — 300+ exercises across 7 major topics
To compile and run the C programs in this repository, you need:
- A C Compiler (GCC, Clang, or MSVC)
- Linux: Usually pre-installed. If not:
sudo apt-get install gcc(Ubuntu/Debian) orsudo dnf install gcc(Fedora) - macOS: Install Xcode Command Line Tools:
xcode-select --install - Windows: Download and install MinGW or use Windows Subsystem for Linux (WSL)
- Linux: Usually pre-installed. If not:
-
Clone the repository
git clone https://github.com/justshobee/ultimate-c-exercises.git cd ultimate-c-exercises -
Navigate to a section (e.g., C Basics)
cd 01_c_basics -
Choose an exercise (e.g., ex01)
cd ex01 ls -la
Inside each exercise directory, you'll find .c source files. Here's how to compile and run them:
# Compile the source file
gcc program_name.c -o program_name
# Run the compiled executable
./program_nameExample:
gcc hello_world.c -o hello_world
./hello_world# Using Clang instead of GCC
clang program_name.c -o program_name
# Compile with warnings enabled (recommended)
gcc -Wall -Wextra program_name.c -o program_nameultimate-c-exercises/
├── 01_c_basics/ # Hello World, syntax, basic I/O, comments (48 exercises)
├── 02_variables_data_types/ # Variables, int, float, char, sizeof() (21 exercises)
├── 03_loops/ # for, while, do-while, nested loops (28 exercises)
├── 04_functions/ # Function definition, parameters, return types (25 exercises)
├── 05_arrays/ # 1D arrays, 2D arrays, array operations (40 exercises)
├── 06_strings/ # String manipulation, character arrays, functions (30 exercises)
├── 07_pointers/ # Pointers basics, dereferencing, arrays of pointers (60+ exercises)
└── README.md # You are here!
48 Exercises | Duration: 1-2 weeks
Start your C journey here! Learn fundamental concepts like program structure, printing output, accepting input, and working with operators.
Topics Covered:
- Hello World program
- Basic syntax and structure
printf()andscanf()functions- Comments and code organization
- Basic operators (arithmetic, relational, logical)
- Conditional statements (if/else)
Best For: Absolute beginners with no programming experience
21 Exercises | Duration: 1 week
Understand how to store and manage data in your programs. Learn about different data types and how to use them effectively.
Topics Covered:
- Variable declaration and initialization
- Data types: int, float, double, char
sizeof()operator- Type casting and conversion
- Variable scope
Best For: Understanding data storage and memory concepts
28 Exercises | Duration: 1-2 weeks
Master iteration concepts to repeat code blocks efficiently. This is essential for working with arrays and processing data.
Topics Covered:
forloopswhileloopsdo-whileloops- Loop control:
breakandcontinue - Nested loops
- Loop patterns and techniques
Best For: Learning iteration and repetition patterns
25 Exercises | Duration: 1-2 weeks
Learn to write reusable, organized code by mastering functions. Functions are building blocks of larger programs.
Topics Covered:
- Function definition and declaration
- Parameters and return types
- Scope and lifetime of variables
- Recursive functions
- Function libraries
Best For: Writing modular and maintainable code
40 Exercises | Duration: 2-3 weeks
Work with collections of data using arrays. Learn both single and multi-dimensional arrays.
Topics Covered:
- 1D arrays: declaration and usage
- 2D arrays and matrices
- Array initialization
- Passing arrays to functions
- Array algorithms (sorting, searching, etc.)
Best For: Managing collections of data
30 Exercises | Duration: 2 weeks
Master string handling—one of the most important skills in C programming!
Topics Covered:
- String basics (character arrays)
- String input/output (
gets(),puts(),fgets()) - String library functions (
strlen(),strcpy(),strcat(), etc.) - String manipulation and comparison
- Common string problems and solutions
Best For: Text processing and manipulation
60+ Exercises | Duration: 3-4 weeks
Pointers are what make C powerful! This advanced topic opens doors to dynamic memory, complex data structures, and more.
Topics Covered:
- Pointer basics: address-of (
&) and dereference (*) operators - Pointer arithmetic
- Arrays and pointers relationship
- Pointers to functions
- Dynamic memory allocation (
malloc(),free()) - Strings as pointers
- Pointer pitfalls and debugging
Best For: Advanced programmers ready to unlock C's full potential
- Start with Section 1: Begin with
01_c_basics/and work through exercises sequentially - Follow the order: Don't skip sections—each builds on previous concepts
- Practice consistently: Spend 30-60 minutes daily on exercises
- Type it out: Don't copy-paste; type every line to build muscle memory
- Experiment: Modify exercises and create variations to deepen understanding
- Jump to relevant sections based on your learning goals
- Use as a reference for C-specific patterns
- Challenge yourself with advanced exercises in each section
- Use as interview preparation
- Understand before moving on — Don't memorize, understand the "why"
- Write clean code — Use meaningful variable names and comments
- Test your code — Try different inputs, including edge cases
- Debug systematically — Use
printf()to trace variable values - Read error messages — They're trying to help you!
- Revisit basics — Go back and refactor old exercises with new knowledge
gcc -Wall -Wextra -std=c99 program.c -o program-Wall— Enable all common warnings-Wextra— Enable extra warnings-std=c99— Use C99 standard (recommended for modern C)
gcc -g -Wall -Wextra program.c -o programSolution: Install a C compiler (see Prerequisites section)
Solution: Make sure you're compiling all .c files if there are multiple
Solution:
- Add
printf()statements to trace execution - Check array bounds and pointer validity
- Use tools like
valgrindto detect memory issues
We welcome contributions! If you have:
- New exercises or topics to add
- Improvements to existing exercises
- Bug fixes or clarifications
- Better explanations or examples
Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes
- Commit:
git commit -m 'feat: Add new exercise on topic X' - Push:
git push origin feature/your-feature - Open a Pull Request
Guidelines:
- Write clear, commented C code
- Follow consistent naming conventions
- Include example input/output
- Test your exercises before submitting
- Inspired by numerous online C programming tutorials and courses
- Thanks to the open-source community for excellent tools like GCC and Clang
- Special thanks to all contributors and learners
Have questions or found an issue?
- Email: Open an issue on GitHub
- Bug Report: GitHub Issues
- Suggestions: Feel free to open a discussion or issue
Keep track of your progress! Here's a template:
- 01_c_basics (all 48 exercises)
- 02_variables_data_types (all 21 exercises)
- 03_loops (all 28 exercises)
- 04_functions (all 25 exercises)
- 05_arrays (all 40 exercises)
- 06_strings (all 30 exercises)
- 07_pointers (all 60+ exercises)
Star this repo if it helps you on your C programming journey!
Made with dedication for C learners worldwide
By justshobee