Programming for Problem Solving

GTU Practical 4

4. Write a C program to interchange two numbers.
#include<stdio.h>  ( this applies in the given code )

#include

int main()
{
int a,b;
printf(“Enter Value of a :”);
scanf(“%d”,&a);
printf(“Enter Value of b :”);
scanf(“%d”,&b);

a=a+b;
b=a-b;
a=a-b;

printf(“\nAfter Swapping Values a = %d b = %d”,a,b);
return 0;
}

OUTPUT

Enter Value of a :5
Enter Value of b :4

After Swapping Values a = 4 b = 5

GTU STUDY