Skip to main content

C Progarmming Examples

C Programming Examples

This page contains a collection examples on basic concepts of C programming like: loops, functions, pointers, structures etc.
Feel free to use the source code on your system.

Popular examples:

C "Hello, World!" Program
C Program to Print an Integer (Entered by the User)
C Program to Add Two Integers
C Program to Multiply two Floating Point Numbers
C Program to Find ASCII Value of a Character
C Program to Compute Quotient and Remainder
C Program to Find the Size of int, float, double and char
C Program to Demonstrate the Working of Keyword long
C Program to Swap Two Numbers
C Program to Check Whether a Number is Even or Odd
C Program to Check Whether a Character is Vowel or Consonant
C Program to Find the Largest Number Among Three Numbers
C Program to Find all Roots of a Quadratic Equation
C Program to Check Leap Year
C Program to Check Whether a Number is Positive or Negative
C Program to Check Whether a Character is an Alphabet or not
C Program to Calculate the Sum of Natural Numbers
C Program to Find Factorial of a Number
C Program to Generate Multiplication Table
C Program to Display Fibonacci Sequence
C Program to Find GCD of two Numbers
C Program to Find LCM of two Numbers
C Program to Display Characters from A to Z Using Loop
C Program to Count Number of Digits in an Integer
C Program to Reverse a Number
C Program to Calculate the Power of a Number
C Program to Check Whether a Number is Palindrome or Not
C Program to Check Whether a Number is Prime or Not
C Program to Display Prime Numbers Between Two Intervals
C Program to Check Armstrong Number
C Program to Display Armstrong Number Between Two Intervals
C Program to Display Factors of a Number
C Programming Code To Create Pyramid and Structure
C Program to Make a Simple Calculator Using switch...case
C Program to Display Prime Numbers Between Intervals Using Function
C Program to Check Prime or Armstrong Number Using User-defined Function
C Program to Check Whether a Number can be Expressed as Sum of Two Prime Numbers
C Program to Find the Sum of Natural Numbers using Recursion
C Program to Find Factorial of a Number Using Recursion
C Program to Find G.C.D Using Recursion
C Program to Convert Binary Number to Decimal and vice-versa
C Program to Convert Octal Number to Decimal and vice-versa
C Program to Convert Binary Number to Octal and vice-versa
C program to Reverse a Sentence Using Recursion
C program to calculate the power using recursion
C Program to Calculate Average Using Arrays
C Program to Find Largest Element of an Array
C Program to Calculate Standard Deviation
C Program to Add Two Matrix Using Multi-dimensional Arrays
C Program to Multiply to Matrix Using Multi-dimensional Arrays
C Program to Find Transpose of a Matrix
C Program to Multiply two Matrices by Passing Matrix to a Function
C Program to Access Elements of an Array Using Pointer
C Program Swap Numbers in Cyclic Order Using Call by Reference
C Program to Find Largest Number Using Dynamic Memory Allocation
C Program to Find the Frequency of Characters in a String
C Program to Count the Number of Vowels, Consonants and so on
C Program to Remove all Characters in a String Except Alphabet
C Program to Find the Length of a String
C Program to Concatenate Two Strings
C Program to Copy String Without Using strcpy()
C Program to Sort Elements in Lexicographical Order (Dictionary Order)
C Program to Store Information of a Student Using Structure
C Program to Add Two Distances (in inch-feet) System Using Structures
C Program to Add Two Complex Numbers by Passing Structure to a Function
C Program to Calculate Difference Between Two Time Periods
C Program to Store Information of Students Using Structure
C Program to Store Information Using Structures with Dynamically Memory Allocation
C Program to Write a Sentence to a File
C Program to Read a Line From a File and Display it
C Program to Display its own Source Code as Output
C Programming Code To Create Pyramid and Pattern

Comments

Popular posts from this blog

C Program to Check Whether a Number is Positive or Negative

C Program to Check Whether a Number is Positive or Negative In this example, you will learn to check whether a number (entered by the user) is negative or positive.    To understand this example, you should have the knowledge of following C programming topics: C Programming Operators C if...else Statement This program takes a number from the user and checks whether that number is either positive or negative or zero. Example #1: Check if a Number is Positive or Negative Using if...else #include <stdio.h> int main () { double number ; printf ( "Enter a number: " ); scanf ( "%lf" , & number ); if ( number <= 0.0 ) { if ( number == 0.0 ) printf ( "You entered 0." ); else printf ( "You entered a negative number." ); } else printf ( "You entered a positive num...

C Program to Print an Integer (Entered by the User)

C Program to Print an Integer (Entered by the User) In this program, integer entered by the user is stored in a variable. Then, that variable is displayed on the screen using printf() function.   To understand this example, you should have the knowledge of following C programming topics: C Programming Constants and Variables C Programming Data Types C Input Output (I/O) Program to Print an Integer #include <stdio.h> int main () { int number ; // printf() dislpays the formatted output printf ( "Enter an integer: " ); // scanf() reads the formatted input and stores them scanf ( "%d" , & number ); // printf() displays the formatted output printf ( "You entered: %d" , number ); return 0 ; } Output Enter a integer: 25 You entered: 25 In this program, an integer variable  number is declared. ...

C Program to Swap Two Numbers

C Program to Swap Two Numbers This example contains two different techniques to swap numbers in C programming. The first program uses temporary variable to swap numbers, whereas the second program doesn't use temporary variables.   To understand this example, you should have the knowledge of following C programming topics: C Programming Data Types C Programming Operators C Input Output (I/O) Example 1: Program to Swap Numbers Using Temporary Variable #include <stdio.h> int main () { double firstNumber , secondNumber , temporaryVariable ; printf ( "Enter first number: " ); scanf ( "%lf" , & firstNumber ); printf ( "Enter second number: " ); scanf ( "%lf" ,& secondNumber ); // Value of firstNumber is assigned to temporaryVariable temporaryVariable = firstNumber ; // Value of secondNumber...