C Programming Examples


C Programming language

C Examples

C is a general-purpose programming language that has played a pivotal role in shaping modern software development. Known for its efficiency and close-to-hardware capabilities. C programming is an excellent language to learn to program for beginners.

Writing programs in C is the best way to learn C programming. The page contains examples programs for basic C concepts. You should go through all of these examples and attempt them on your own.

This page contains a list of c programs on Fundamental C concepts, Array, Strings, Matrix, Recursion, Geometrical and Mathematical problems. All of the example programs here are compiled successfully, executes and verified with sample input and output. Most of the program here will work on most standard compilers.

Feel free to Contact Us, If you find any bug in any of the below mentioned programs.

Fundamental C Programs

C program to print Hello World
C Program to add two numbers
C program for addition, subtraction, multiplication, division and modulus of two numbers
C program to check whether an alphabet is a vowel or consonant
C program for Input/Output of Integer, Character and Floating point numbers
C program to add two numbers using pointers
C program to add two complex numbers
C program to add n numbers
C program to print current date and time
C program to check year is leap year or not
C Program to print fibonacci series
C Program to calculate factorial of a number
C program to print digit of a number in words
C program to print ASCII value of a character
C program to find square root of a number using sqrt function
C program to find total, average and percentage marks of subjects
C program to calculate simple interest
C program to calculate compound interest
C Program to Find Largest of Three Numbers

If Else C Programs

C program to find maximum of two numbers
C program to find maximum of three numbers
C program to check whether a number is positive, negative or zero
C program to check whether a character is alphabet or not
C program to check whether a character is alphabet or digit
C program to print days of week in words using if else ladder
C program to print number of days in any month
C program to check whether three angles of triangle is valid or not
C program to check whether three sides of triangle is valid or not
C program to check whether a triangle is equilateral, isosceles or scalene.
C program to enter cost price and selling price and calculate profit or loss

Switch Case C Programs

C program to check whether a character is vowel or consonant using switch statement
C program to print name of days in week using switch statement
C program to check whether a number is odd or even using switch statement
C program to find maximum of two numbers using switch statement

Conditional Operator C Programs

C program to find maximum of two numbers using conditional operator
C program to find maximum of three numbers using conditional operator
C program to check a number is odd or even using conditional operator
C program to check decimal digit character using conditional operator

Loops C Programs

C program to print natural numbers from 1 to N using for, while and do-while loop
C program to print natural numbers in reverse order from N to 1
C program to print even numbers between 1 to N using for and while loop
C program to print odd numbers between 1 to N using for and while loop
C program to find sum of all even numbers between 1 to N using for loop
C program to find sum of all odd numbers between 1 to N using for loop
C program to split an amount into notes
C program to find product of digits of a number using while loop
C program to find sum of least and most significant digits of a number
C program to print all factors of a number using for loop
C program to find gcd of two numbers
C program to print all prime numbers between 1 to N using for loop
C program to find perfect numbers between 1 to N using for loop
C program to print all prime factors of a number
C program to find sum of prime numbers between 1 to N
C program to find ones complement of a binary number
C program to find twos complement of a binary number

Mathematical C Programs

C program to check odd or even numbers
C program to reverse a number
C program to swap two numbers
C program to add digits of a number
C program to check a number is palindrome or not
C program to check armstrong number
C program to generate armstrong numbers
C program to calculate power of a number
C program to find hcf and lcm of two numbers
C Program to find nPr and nCr
C program to generate random numbers
C program to find all roots of quadratic equation
C program to check whether a number is perfect number
C program to check whether a number is magic number
C program to check whether a number is prime or not
C program to print multiplication table of a number
C program to count number of digits in an integer

Strings C Programs

C program to read and print string
C program to find length of string
C program to reverse a string
C program to copy a string
C program to compare two strings
C program to concatenate strings
C program to check string is palindrome
C program to convert string to integer
C program to remove vowels from a string
C program to remove extra spaces from string
C program to swap two strings
C Program to find frequency of characters in a string
C program to convert lowercase string to uppercase
C program to convert uppercase string to lowercase
C program to find a substring from a given string
C program to check if two strings are anagram
C program to sort characters of a string
C program to count vowels, consonants, digits and spaces in a string
C program to divide a string into two equal strings

Matrix C Programs

C program to add two matrix
C Program for subtraction of two matrix
C Program to find transpose of matrix
C Program to find sum of diagonal elements of matrix
C program to find scalar multiplication of a matrix
C program to print lower triangular matrix
C program to print upper triangular matrix
C program to compare two matrix
C program to check identity matrix
C Program to print a matrix diagonally
C Program for matrix multiplication
C Program to sum each row and column of matrix
C Program swap major and minor diagonals of a square matrix
C Program to find sum of upper triangular matrix
C Program to find sum of lower triangular matrix
C Program to check sparse matrix
C Program to check symmetric matrix

Array C Programs

C Program to read and print elements of an array
C Program to find sum of all elements of an array
C Program to find maximum elements in an array
C Program to find minimum element in an array
C program to insert an element in an array
C program to delete an element from an array
C program to reverse an array
C program to find second largest element in array
C program to delete duplicate elements from an array
C program to delete duplicate elements from a sorted array
C Program to print unique elements of an unsorted array
C program to find maximum and minimum element of an array
C Program to create a duplicate array
C program to find number of duplicate elements in an array
C Program to print all negative numbers of an array
C Program to count all negative numbers in an array
C Program to find count of each element of an array
C Program to search an element in an array
C Program to sort elements of an array in increasing order
C Program to sort elements of an array in decreasing order

Recursion C programs

C program to print fibonacci series using recursion
C program for palindrome check using recursion
C program to reverse a string using recursion
C program to find sum of array elements using recursion
C program to find power of a number using recursion
C program to find sum of digits of a number using recursion
C program to find factorial of a number using recursion
C program to reverse a number using recursion
C program to reverse an array using recursion

Geometrical C programs

C program to find circumference(perimeter) of a circle
C program to find the perimeter of a rectangle
C program to calculate area of a circle
C program to calculate area of a rectangle
C program to calculate area of a parallelogram
C program to calculate area of a square
C program to calculate area of a rhombus
C program to calculate area of a trapezium
C program to calculate area of a right angled triangle
C program to calculate area of an equilateral triangle
C program to calculate area of any triangle
C program to calculate volume and total surface area of cube
C program to calculate volume and total surface area of cuboid
C program to calculate volume and total surface area of cone
C program to calculate volume and total surface area of cylinder
C program to calculate volume and total surface area of sphere
C program to find third angle of a triangle

Miscellaneous C programs

C Program to generate arithmetic progression(AP) series
C Program to generate geometric progression(GP) series
C Program to generate harmonic progression(HP) series
C Program to print Floyd's triangle
C program to make a simple calculator using switch statement
C program to print triangle and pyramid patterns of star(*)
C program to multiply two numbers without using arithmetic operators
C program to print pascal triangle till N rows
C program to convert hexadecimal number to binary number system
C program to convert decimal numbers to binary numbers
C program to convert decimal number to octal number
C program to convert binary numbers to octal number using function
C program to convert temperature from celsius to fahrenheit
C program to convert kilometer to miles
C program to convert number of days to week, months and years
C program to convert a binary number to octal number system
C program to convert binary number to decimal number system
C program to convert a binary number to hexadecimal number system
C program to convert octal number to binary number system
C program to convert a octal number to decimal number system
C program to convert octal number to hexadecimal number system
C program to convert decimal number to hexadecimal number system
C program to convert hexadecimal number to decimal number system