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. Required fields are marked *

Shopping Basket
Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare
Verified by MonsterInsights