Write a Program in C to Cycle Swapping

Sure, swapping three numbers involves exchanging the values of three variables. The basic idea is to use a temporary variable to hold the value of one of the variables while you perform the swaps. Here’s a simple C program that demonstrates swapping between three numbers:

Program :

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

Output :

2 thoughts on “Write a Program in C to Cycle Swapping”

Leave a Comment

Your email address will not be published.

Shopping Basket
Verified by MonsterInsights