Swapping of two numbers using third variable.
#include<stdio.h>
#include<conio.h>
void main()
{
int a=10,b=20,c=0;
clrscr();
printf("a=%d \nb=%d",a,b);
c=a;
a=b;
b=c;
printf("After swapping values of a & b are: \n ");
printf("a=%d \nb=%d",a,b);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a=10,b=20,c=0;
clrscr();
printf("a=%d \nb=%d",a,b);
c=a;
a=b;
b=c;
printf("After swapping values of a & b are: \n ");
printf("a=%d \nb=%d",a,b);
getch();
}
No comments:
Post a Comment