Write a program Swap two variables.
Program by visual studio
//Write a program to Swap two variables
#include<stdio.h>
#include<conio.h>
void main()
{
int n,m,temp;
printf("\nEnter a Number=");
scanf("%d",n);
printf("\nEnter a Second Number=");
scanf("%d",m);
temp=n;
n=m;
m=temp;
printf("\n Swap number N=%d M=%d",n,m);
getch();
}
//Program by turbo c/c++
//Write a program swap two number
#include<stdio.h>
#include<conio.h>
void main()
{
int a=10,b=5,temp;
clrscr();
printf("\n Without swap A=%d B=%d",a,b);
temp=a;
a=b;
b=temp;
printf("\n swap\n A=%d B=%d",a,b);
getch();
}
Output:-
Related Program (Please Check)
0 Comments