Swapping Two Numbers Program in C (Chapter 1 Program 5)
Also visit our YouTube Channel Tech Eos VISIT CHANNEL /* 5. Write a program to store and interchange two numbers in variables a and b. */ #include<stdio.h> #include<conio.h> void main() { int a , b , c ; clrscr(); printf("\nEnter value of a : "); scanf("%d" , &a); printf("\nEnter value of b : "); scanf("%d" , &b); printf("\n\nBefore Swapping\n\n"); printf("\na = %d" , a); printf("\nb = %d" , b); // Logic c = a; a = b; b = c; printf("\n\nAfter Swapping\n\n"); printf("\na = %d" , a); printf("\nb = %d" , b); getch(); }