Swap two number

For example :
a = 5;
b = 8;
a = 8;
b = 5;


Today we write a program in c programming language that swap two number using third variable. So now let's start the code of this program...


int main()
    int a, b;
    printf("Enter the value of a : ");
    scanf("%d", &a);
    printf("Enter the value of b : ");
    scanf("%d", &b);
    int temp;
    temp = a;
    a = b;
    b = temp;
    printf("The value of a is %d and b is %d", a, b);

    return 0;


Enter the value of a : 5
Enter the value of b : 8
The value of a is 8 and b is 5


Login is mandatory to comment Please login

Recommended Posts

Swap two number without using third variable | C programming language

Write a program Swap two number withtout using third variable in c programming language.

Fibonacci Series | Fibonacci Series in C | @lapmos

Fibonacci numbers ( sequence ) is a set of numbers that start with 1 or 0 followed by a 1 proceeds on the rule that each number.

Palindrome | Palindrome program in c | Palindrome Number

Write a program in c to check that the given number is palindrome or not?

Pascal Triangle | C programming

pascal triangle program in c | Write a c program to print the pascal triangle.

Leap Year | Leap year program in c

Year is divisible by completely 4,100,400 then called that year is leap year.

Perfect Number in C Programming

What is Perfect Number? Perfect Number is a positive integer number that is equal to the sum of the its possible factors.
For Example : 6 is a Perfect Number