PROCEDURE:-
1.input values for a and b
2. compute a= a+b
3. compute b =a-b
4. compute a=a-b
5.print value of a and b after swapping
CODE:-
#include<stdio.h>
void main()
{
int a,b,t;
printf(“enter value for a,b”);
scanf(“%d %d”,&a,&b);
printf(“before swapping a=%d b=%d”,a,b);
a=a+b;
b=a-b;
a=a-b;
printf(“after swapping a=%d b=%d”,a,b);
}
Input:- enter value for a,b
a=5, b=6
Output:- after swapping a=6 b=5
1.input values for a and b
2. compute a= a+b
3. compute b =a-b
4. compute a=a-b
5.print value of a and b after swapping
CODE:-
#include<stdio.h>
void main()
{
int a,b,t;
printf(“enter value for a,b”);
scanf(“%d %d”,&a,&b);
printf(“before swapping a=%d b=%d”,a,b);
a=a+b;
b=a-b;
a=a-b;
printf(“after swapping a=%d b=%d”,a,b);
}
Input:- enter value for a,b
a=5, b=6
Output:- after swapping a=6 b=5
Comments
Post a Comment