Write a c program to swap two numbers

Program:

#include <stdio.h>
#include <conio.h>
int main(){
int a, b, c;
printf(“Enter two numbers \n”);
scanf(“%d %d”, &a, &b);
printf(“\na:%d\n b:%d\n”,a,b);
c = a;
a = b;
b = c;
printf(“\nAfter Swap\n”);
printf(“\na:%d\n b:%d\n”,a,b);
getch();
return 0;
}

Output:

Enter two numbers
6 7
a:6
b:7
After Swap
a:7
b:6

Scroll to Top