PROCEDURE:-
1.input values for a and b
2. store value of a in t
3. store value of b in a
4. store value of t in 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);
t=a;
a=b;
b=t;
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. store value of a in t
3. store value of b in a
4. store value of t in 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);
t=a;
a=b;
b=t;
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