C Programming Examples
Master C programming with our comprehensive collection of practical examples. Each program includes detailed explanations, step-by-step execution, and sample outputs.
Browse by Category
Basic Programs
Fundamental C programs for beginners
Hello World Program
The classic first program in C
Print Your Own Name
Display name entered by user
Print an Integer Entered By User
Read and display an integer
Add Two Numbers
Add two integers entered by user
Check Whether a Number is Prime
Determine if a number is prime
Multiply Two Floating-Point Numbers
Multiply two decimal numbers
Print ASCII Value of a Character
Get ASCII value of a character
Swap Two Numbers
Swap values using temp variable
Calculate Fahrenheit to Celsius
Temperature conversion program
Find Size of int, float, double, char
Find size of data types using sizeof
Add Two Complex Numbers
Add complex numbers using structures
Print Prime Numbers From 1 to N
Display all primes up to N
Find Simple Interest
Calculate simple interest
Find Compound Interest
Calculate compound interest
Area and Perimeter of Rectangle
Calculate area and perimeter
Control Flow
Decision making, loops, and conditional programs
Check Positive, Negative, or Zero
Determine sign of a number
Check Whether Number is Even or Odd
Determine if number is even or odd
Check Whether Character is Vowel or Consonant
Character classification
Find Largest Number Among Three
Find maximum among three numbers
Calculate Sum of Natural Numbers
Calculate 1+2+3+...+n
Print Alphabets From A to Z Using Loop
Display all alphabets
Check Leap Year
Determine if year is leap year
Find Factorial of a Number
Calculate n! using loop
Make a Simple Calculator
Calculator using switch-case
Generate Multiplication Table
Generate multiplication table
Print Fibonacci Series
Print Fibonacci sequence
Find LCM of Two Numbers
Find least common multiple
Check Armstrong Number
Verify Armstrong property
Display Armstrong Numbers Between 1 to 1000
Find all Armstrong numbers in range
Display Armstrong Numbers Between Two Intervals
Find Armstrong numbers in given range
Reverse a Number
Reverse digits of a number
Check Whether Number is Palindrome
Number reads same forwards/backwards
Check Whether Number is Prime
Prime check using loops
Display Prime Numbers Between Intervals
Print primes in a range
Check Whether Number is Neon Number
Check if sum of digits squared equals number
Find All Factors of a Natural Number
Find all divisors
Sum of Fibonacci Numbers at Even Indexes
Sum Fibonacci at even positions
Pattern Printing
Star, number, and character patterns
Print Simple Pyramid Pattern
Print pyramid of stars
Print Given Triangle
Print right-angled triangle
Print 180° Rotation of Simple Pyramid
Print rotated pyramid
Print Inverted Pyramid
Print inverted star pyramid
Print Number Pattern
Print pattern with numbers
Print Character Pattern
Print pattern with alphabets
Print Continuous Character Pattern
Print continuous alphabet pattern
Print Hollow Star Pyramid
Print hollow pyramid
Print Inverted Hollow Star Pyramid
Print inverted hollow pyramid
Print Hollow Star Pyramid in Diamond Shape
Print hollow diamond pattern
Print Full Diamond Shape Pyramid
Print full diamond shape
Print Pascal's Pattern Triangle Pyramid
Print Pascal triangle
Print Floyd's Pattern Triangle Pyramid
Print Floyd triangle
Print Reverse Floyd's Pattern Triangle
Print reversed Floyd triangle
Functions & Recursion
Functions and recursive programs
Check Prime Number By Creating Function
Function to check prime
Display Prime Numbers Using Functions
Print primes using function
Find All Roots of Quadratic Equation
Find roots using formula
Check if Number is Sum of Two Primes
Express number as sum of primes
Sum of Natural Numbers Using Recursion
Sum using recursion
Factorial Using Recursion
Recursive factorial calculation
Find GCD Using Recursion
Euclidean algorithm recursive
Reverse a Stack Using Recursion
Reverse stack recursively
Calculate Power Using Recursion
Calculate x^n recursively
Arrays & Matrices
Array manipulation and matrix operations
Print a 2D Array
Display 2D array elements
Find Largest Element in Array
Find maximum value
Find Maximum and Minimum in Array
Find both min and max
Search Element in Array (Binary Search)
Search in sorted array
Calculate Average of Array Elements
Calculate array average
Sort Array Using Bubble Sort
Sort using bubble sort
Sort Array Using Merge Sort
Sort using merge sort
Sort Array Using Selection Sort
Sort using selection sort
Sort Array Using Insertion Sort
Sort using insertion sort
Sort Array in Descending Order
Sort from high to low
Sort Array in Ascending Order
Sort from low to high
Remove Duplicate Elements From Sorted Array
Remove duplicates
Merge Two Arrays
Combine two arrays
Remove All Occurrences of Element
Remove specific element
Find Common Array Elements
Find intersection
Copy All Elements to Another Array
Array copy
Array Rotation
Rotate array elements
Sort 2D Array Across Rows
Sort each row of 2D array
Check Whether Two Matrices Are Equal
Compare two matrices
Find the Transpose of Matrix
Transpose a matrix
Find Determinant of Matrix
Calculate determinant
Find Normal and Trace of Matrix
Calculate normal and trace
Add Two Matrices
Matrix addition
Multiply Two Matrices
Matrix multiplication
Print Boundary Elements of Matrix
Print border elements
Compute Sum of Diagonals of Matrix
Sum diagonal elements
Strings
String manipulation programs
Add or Concatenate Two Strings
Join two strings
Add 2 Binary Strings
Binary string addition
Get Non-Repeating Character From String
Find first unique character
Check if String is Palindrome
Check palindrome string
Reverse an Array or String
Reverse string characters
Reverse a String Using Recursion
Recursive string reverse
Find the Length of a String
Find length without strlen
Sort a String
Sort string alphabetically
Check For Pangram String
Check if contains all alphabets
Print First Letter of Each Word
Extract initials
Determine Unicode Code Point at Index
Get character code
Remove Leading Zeros
Strip leading zeros
Compare Two Strings
Compare strings
Compare Two Strings Lexicographically
Dictionary order comparison
Insert a String into Another String
Insert substring
Split String into Sub-Strings
Split by delimiter
Conversions
Type and number system conversions
Boolean to String Conversion
Convert bool to string
Float to String Conversion
Convert float to string
Double to String Conversion
Convert double to string
String to Long Conversion
Convert string to long
Long to String Conversion
Convert long to string
Int to Char Conversion
Convert integer to character
Char to Int Conversion
Convert character to integer
Octal to Decimal Conversion
Convert octal to decimal
Decimal to Octal Conversion
Convert decimal to octal
Hexadecimal to Decimal Conversion
Convert hex to decimal
Decimal to Hexadecimal Conversion
Convert decimal to hex
Decimal to Binary Conversion
Convert decimal to binary
Binary to Decimal Conversion
Convert binary to decimal
Pointers
Pointer-based programs
Return a Pointer from a Function
Function returning pointer
Declare 2D Array of Pointers
2D pointer array declaration
Find Largest Element Using Pointers
Array max with pointers
Swap Two Numbers Using Pointers
Swap using pointers
Sort an Array Using Pointers
Pointer-based sorting
Sort a 2D Array of Strings
Sort string array
Check Palindrome Using Pointers
Palindrome with pointers
Create Copy of Singly Linked List
Copy linked list recursively
Structures & Unions
User-defined data types
Store Information of Students Using Structure
Student data structure
Store and Sort Student Records by Name
Sort structures by name
Add N Distances in inch-feet Using Structures
Distance calculation
Add Complex Numbers by Passing Structure
Complex number addition
Store and Sort Student Records by Age or ID
Sort by numeric field
Read/Write Structure to a File
Structure file I/O
Flexible Array Members in Structure
Dynamic struct arrays
File I/O
File handling programs
Create a Temporary File
Temporary file creation
Read/Write Structure to a File
Structure file operations
Rename a File
File renaming
Make a File Read-Only
Set file permissions
Compare Two Files and Report Mismatches
File comparison
Copy One File into Another File
File copy operation
Print Patterns Matching From a File
Pattern search in file
Append Content of One Text File to Another
File append operation
Read and Write Content Between Files
File transfer
Read and Print Files From a Zip File
Zip file reading
Date & Time
Date and time programs
Format Time in AM-PM Format
AM/PM time formatting
Print Digital Clock with Current Time
Display running clock
Display Dates in Different Formats
Date formatting
Display Current Date and Time
Show system date/time
Maximize Time by Replacing _ in 24-Hour Format
Time puzzle problem
Convert Local Time to GMT
Timezone conversion
Convert Hours into Minutes and Seconds
Time unit conversion
More C Programs
Miscellaneous useful programs
Show Runtime Exceptions
Runtime error examples
Show Types of Errors
Different error types
Show Unreachable Code Error
Unreachable code demo
Find Quotient and Remainder
Division operations
Find the Initials of a Name
Extract name initials
Draw a Circle in Graphics
Graphics programming
Print Source Code of Program Itself
Quine program
Want In-Depth Learning?
These examples are great for practice. For comprehensive explanations of C concepts, explore our structured tutorials.
Browse All Tutorials