Problem Description
write a program to swap two numbers using a temporary variable
Input and Output Format:
Refer sample input and output for formatting specification.
All float values are displayed correct to 2 decimal places.
All text in bold corresponds to input and the rest corresponds to output.CODING ARENA
#include <stdio.h>
int main()
{
int x,y,tmp;
scanf("%d%d",&x,&y);
printf("Before Swapping\nx=%d\ny=%d",x,y);
tmp=x;
x=y;
y=tmp;
printf("\nAfter Swapping\n%d\n%d",x,y);
return 0;
}
Test Case 1
Input (stdin)10 20
Expected OutputBefore Swapping x=10 y=20 After Swapping 20 10
Test Case 2
Input (stdin)4 5
Expected OutputBefore Swapping x=4 y=5 After Swapping 5 4
No comments:
Post a Comment