C Program to Swapping Between two Numbers

Swapping two numbers means exchanging the values of two variables. In C program, you can achieve swapping using a temporary variable or without using a temporary variable. I’ll provide examples for both cases.

Program :

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
printf(“Enter the First Number : “);
scanf(“%d”,&a);
printf(“Enter the Second Number : “);
scanf(“%d”,&b);
c=a;
a=b;
b=c;
printf(“\nAfter Swapping…\nFirst Number : %d”,a);
printf(“\nSecond Number : %d”,b);
}

Output :

Leave a Comment

Your email address will not be published.

Shopping Basket
Verified by MonsterInsights