Swapping Numbers
2 posters
Page 1 of 1
Re: Swapping Numbers
#include<stdio.h>
int main()
{
int a, b;
printf("\nEnter value for num1 & num2 : ");
scanf("%d %d", &a, &b);
a = a + b;
b = a - b;
a = a - b;
printf("\nAfter swapping value of a : %d", a);
printf("\nAfter swapping value of b : %d", b);
return (0);
}
int main()
{
int a, b;
printf("\nEnter value for num1 & num2 : ");
scanf("%d %d", &a, &b);
a = a + b;
b = a - b;
a = a - b;
printf("\nAfter swapping value of a : %d", a);
printf("\nAfter swapping value of b : %d", b);
return (0);
}
vinoveera- Posts : 7
Points : 22699
Join date : 2015-06-27
Good answer
vinoveera wrote:#include<stdio.h>
int main()
{
int a, b;
printf("\nEnter value for num1 & num2 : ");
scanf("%d %d", &a, &b);
a = a + b;
b = a - b;
a = a - b;
printf("\nAfter swapping value of a : %d", a);
printf("\nAfter swapping value of b : %d", b);
return (0);
}
Good answer... Keep it up!!
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|