This page lists 130+ C programs with examples — every program on the site, organised by topic, from simple beginner programs to sorting algorithms, searching, data structures, matrices, strings, and file handling. Each one is a complete, compilable C program with source code and output. Bookmark this page and use it as your practice roadmap: work through a topic, then test yourself with the C aptitude questions.
Jump to a topic: Basics · Arrays · Sorting · Searching · Graphs & Trees · Numbers · Files · Matrix · Linked Lists, Stacks & Queues · Strings
New to C? Set up your compiler first (it takes only a few minutes): Install GCC on Windows 11, on macOS Tahoe, or skip installation entirely with an online C compiler. For the best experience, set up VS Code for C programming.
Simple C Programs
- Arithmetic Operators
- ++ and — Operators
- Global and Internal Variables
- Extern Variables
- Bitwise operators
- Size of data Types
- Switch Statement
- Ternary Condition(?)
- Format
- Enumeration Example
- Functions
- Multiplication table
- Do statement
- Sum Digits of Integer
- Pyramid Pattern
- Name Sort
- Variable Values
- Data Types
- Surface area and Volume of Cube
- Roots of Quadratic equation
- Find Variance,Mean, Standard Deviation
- Simple Interest
- Area of Circle
- Find Triangle Type
- Hello World
- Area of Isosceles Triangle
- Biggest of three numbers
- Sleep() Example
- Unions example
- #Define pre processor
- #if,#else,#endif
- Convert days to years,weeks and Days
- Time Functions
C Programs on Arrays
- Insert into Array
- Array summation
- Sum and Average
- Array Deletion
- Split the Array
- Size of Array
- Sum of 2D array using DMA
- Array Addition
- Array Search
- Cyclically Permute the Array
C Programs For Sorting Algorithms
- Bubble Sort
- Insertion Sort
- Heap Sort
- Merge Sort
- Quick Sort
- Shell Sort
- Bucket Sort
- Radix Sort
- Selection Sort
- String Sort
- Sort Linked List
- Topological Sort
C Programs for Searching
C Programs on Graphs and Trees
Various C Programs on Numbers
- Binary to Decimal
- Binary to Decimal,Octal,Hexadecimal
- Roman to Decimal
- Decimal to Binary
- Palindrome
- Binary to 2’s complement
- GCD and LCM
- Fibonacci Numbers
- Find Quadrant
- Prime Number
- Complex Numbers
- Sum of Digits
- Swap Numbers
- Cos(x)
- Sin(x)
- X^N
- Polynomial Series
- ODD or EVEN
- nPr and nCr.
- Square and Cube
- Armstrong Number
- Perfect Number
- Random Number
C Programs on Files and File handling
- File operations
- Disk Read
- File Copy
- Reverse File contents
- fgets function
- Sequential File
- File characters count
C Programs on Matrix
- Addition, Subtraction and Trace of Matrices
- Transpose of a matrix
- Multiplication of Matrices
- Elements Sum of a Matrix
- Equal matrices
- Identity Matrix
- Even and Odd elements in a Matrix
- Inter change diagonal Elements of a Matrix
- Sort Row and Column of a Matrix
- Sparse Matrix
- Inverse of a Matrix
C Programs on Linked List, Stack & Queues
- Linear Queue
- Priority ASC order Queue
- Priority DSC order Queue
- Reverse a Linked List
- Two Stacks on single array
- Circular Queue
- Multiple Priority Queue
- Linked List Creation
- Linked List Operations
- Singly Linked List
- Doubly Linked list
- Stack Implementation
- Sequential File
- Infix to Postfix
- Postfix Evaluation
- Binary Search Tree
- Stack using Linked List
- Queue using Linked List
- Stack using Arrays
C Programs on Strings
- Compare Strings
- String Lower to Upper
- String Concatenation
- Word Count
- Palindrome
- Insert a Substring
- Character Deletion
- String Sort
- Name Sort
- Vowels or Consonants
Go Deeper
Once you’re comfortable with the programs above, these are the site’s in-depth resources:
- K&R C Solutions — all 91 exercises from The C Programming Language, with explanations and difficulty ratings
- Pointers in C — complete guide
- Recursion in C — complete guide
- Structures in C — complete guide
- File Handling in C — complete guide
- 50 C Aptitude Questions with Answers — predict-the-output practice for interviews
Practice on the go: our free C Programming Quiz app for Android has 150+ questions across 9 categories covering everything in this list — pointers, arrays, strings, operators, and more.