C Program To Swap Two Numbers

PROGRAM :

#include<stdio.h>
int main()
{
    int a,b,temp;
    printf("Enter the value of A\n");
    scanf("%d",&a);
    printf("Enter the value of B\n");
    scanf("%d",&b);
    printf("\nBefore swapping\nA = %d\nB = %d \n",a,b);
    temp = a;
    a = b;
    b = temp;
    printf("\nAfter swapping\nA = %d\nB = %d \n",a,b);
}




OUTPUT :

Enter the value of A
2
Enter the Value of B 
3

Before swapping
A = 2
B = 3

After swapping
A = 3 
B = 2

Post a Comment

0 Comments