C Programming Examples

This page contains C programming examples with solution code and output tested on Linux system. It covers examples on C programming concepts like do while loop, while loop, for loop, arrays, strings, functions, recursion, pointers, command line arguments, preprocessor directives, file handling, structures, sorting algorithms.

Note: C programs based on bitwise operators, nested structures and unions, handling text (.txt) files and binary file handling will be added soon. Also complex real world problem solutions using C programming language will be added soon and pdf support will be provided as soon as possible so you can download the programs and use them even if you are offline. Stay tuned for the updates.


Simple C programs:

  1. C Program For Area of Circle
  2. Find Area To Be Painted In C
  3. Perform All Arithmetic Operations In C
  4. Print Name of Color In C
  5. Print Entered Digit In Word In C
  6. C Program To Calculate Gross Salary
  7. C program to find profit and loss
  8. C Program To Accept Annual Salary And Print Tax
  9. Calculate Perimeter And Area of Ring In C
  10. C Program To Find Distance And Velocity
  11. Find quadrant in which point lies in c
  12. C Program To Find Roots of Quadratic Equation In C
  13. Check First Number is Between Second And Third In C
  14. C Program To Find Number of Currency Notes
  15. C Program To Calculate Surface Area And Volume of Cuboid
  16. C Program To Calculate Circumference of Circle
  17. Check An Alphabet is Uppercase Or Lowercase In C
  18. C Program To Find Surface Area And Volume of Cylinder
  19. C Program To Check Whether The Number is Divisible By 5 And 7
  20. Check triangle is valid or not in c
  21. Check time is correct or not in c
  22. C Program To Accept Temperature in Fahrenheit And Print it in Celsius And Kelvin
  23. C Program To Find Arithmetic Mean And Harmonic Mean of Two Numbers
  24. C Program To Swap Two Numbers
  25. C Program To Find Distance Between Two Points
  26. Check whether character is digit or not in c
  27. C Program To Display Next And Previous Character of Given Character
  28. C Program To Find Minimum And Maximum of Three Numbers
  29. C Program To Check Number is Even or Odd
  30. C Program To Check Character is Vowel or Consonant
  31. C Program To Display ASCII Value of a Character
  32. C Program To Check Given Year is Leap or Not
  33. C Program To Display A Digit in Word
  1. Menu Driven C Program To Perform Operations on Two Points
  2. C Program To Perform Arithmetic Operations On Two Numbers
  3. C Program To Perform Different Operations On Two Numbers
  4. C program to display number in words
  5. C Program To Accept Radius From User And Perform Different Operation It

C Programs Using Do While Loop:

  1. C Program To Check Perfect Number
  2. C Program To Reverse Given Number
  3. C Program To Compute Power

C Programs Using While Loop:

  1. C Program To Check Given Number is Armstrong Number or Not
  2. C Program To Print Sum of Digits of A Number
  3. C program to count digits of a number
  4. C program to count words characters and lines till user enters eof
  5. C program to find longest line
  6. C program to convert binary number into decimal
  7. C program to convert binary number to octal
  8. C program to convert binary number to hexadecimal
  9. C program to convert decimal number into octal
  10. C program to convert decimal number to hexadecimal
  11. C program to convert octal number to binary
  12. C Program to Convert Octal to Decimal
  13. C program to convert hexadecimal to binary

C Programs Using For Loop:

  1. C Program To Display Prime Numbers Between A Range
  2. C Program To Display Tables For a Range
  3. C Program To Display First n Fibonacci Numbers (0,1,1,2,3,....
  4. C Program To Calculate Factorial of A Number
  5. C Program For Armstrong Number Between 1 to 500
  6. C Program To Display Multiplication Table Having n Multiples
  7. C Program For Prime Number
  8. C program to display even numbers
  9. C program to display series x+3x+5x+7x+....

C Programs For Patterns:

  1. C Program For Numbers Triangle (Pattern)
  2. C Program To Display Decreasing Star Triangle (Pattern)
  3. C Program To Print Triangle of Alphabets (Pattern)
  4. C Program To Display Decreasing Triangle of Alphabets (Pattern)
  5. C program to print or display diamond pattern
  6. C program to print heart star pattern

C Programs on Arrays:

  1. C Program To Add Integers of Two Arrays
  2. C Program To Add Two Matrices
  3. C Program To Check Unit Matrix
  4. C Program To Check Whether The Number is Present in The Array or Not
  5. C Program To Find Maximum Number From Array
  6. C Program To Find Minimum Number From Array
  7. C Program To Print Array In Reverse Order
  8. C Program To Print Sum of Integers of Array
  9. C Program to Calculate Sum of Array Elements Using Pointer
  10. C Program to Calculate Sum of Array Elements Using Pointers as Arguments
  11. C Program To Find Transpose of A Matrix
  12. C program to count frequency of each element in an array
  13. C program to find average of array
  14. C Program to Delete Integer From Array

C Programs on Strings:

  1. C Program To Check Whether The String is Palindrome or Not
  2. C Program to check whether the character is present in the string or not
  3. C Program To Alter Sentence By Replacing Space By *
  4. C Program To Accept n Strings And Display The Largest
  5. C Program To Perform Different Operations On Strings
  6. C Program To Sort Words In Dictionary Order
  7. Write user defined functions for strcat, strcmp, strupr, strrev
  8. C Program To Display String In Reverse Order Using Recursion

C Programs on Functions:

  1. C Program To Check Even or Odd Using a Function
  2. C Program To Find Factorial of A Number Using Function
  3. C Program To Check Armstrong Number Using Function
  4. C Program To Check Given Number is Prime or Not Using Function
  5. C Program To Check Given Character is Vowel or Not Using Function
  6. C Program To Swap Two Numbers Using A Function
  7. C Program To Check Leap Year Using Function
  8. C Program For User Defines Power Function
  9. C Program To Find Minimum Number In Array Using Function Up To Certain Position
  10. C Program To Find Maximum Number In Array Using Function Up To Certain Position
  11. C program to convert roman number into decimal
  12. C program to convert decimal number into it roman equivalent

C Programs on Recursion:

  1. C Program To Find Factorial Using Recursion
  2. C Program To Find nth Fibonacci Number Using Recursion
  3. C Program to Find Sum of Digits of a Number Using Recursion
  4. C Program to Reverse Number Using Recursion
  5. C Program To Find Product of Two Numbers Using Recursion
  6. C Program to Check Number is Prime or Not Using Recursion

C Programs on Pointers

  1. C Program To Print Address of Memory Location Using Pointer
  2. C Program To Swap Two Integers Using A Pointer

C Programs on Command Line Arguments And Preprocessor Directives:

  1. C Program To Accept Three Integers As Command Line Arguments And Find Minimum,Maximum And Average
  2. C Program To Compare Two Strings Using Macro
  3. Check Integers Are Equal Or Not Using Macro
  4. C Program For Finding The Largest of Two Numbers Using Macros

C Programs on Structures:

  1. C Program To Create A Structure Employee
  2. C Program To Create Structure Student And To Perform Various Operations On It
  3. C Program To Create A Structure Library I
  4. C Program To Create A Structure Library II

C Programs on File Handling:

  1. C Program To Copy Contents To Another File
  2. C Program To Count Number of Words,Lines Characters In A File

C Programs on Sorting Algorithms:

C Programs on Bubble Sort:

  1. C Program To Sort Array Elements In Ascending Order Using Bubble Sort
  2. C Program For Bubble Sort On Random Array (Ascending Order)
  3. C Program For Bubble Sort On Random Array (Descending Order)
  4. C Program To Sort Array Elements In Descending Order Using Bubble Sort
  5. C Program to Sort File Using Bubble Sort
  6. C Program to Sort File On Names In Alphabetical Order Using Bubble Sort

C Programs on Insertion Sort:

  1. C program for insertion sort
  2. C Program For Insertion Sort On Random Array (Ascending Order)
  3. C Program For Insertion Sort On Random Array (Descending Order)

C Programs on Quick Sort:

  1. C Program For Quick Sort

C Programs on Merge Sort:

  1. C Program For Merge Sort

C programs on searching techniques

  1. C program for linear search
  2. C program for binary search