Two numbers are input through the keyboard into two locations C and D. Write a program in C to interchange the contents C and D.
#include <stdio.h>
#include <conio.h>
void main() {
int a=10, b=15;
clrscr();
printf("Old sequence: ");
printf("\na = %d \nb = %d", a, b);
a=a+b;
b=a-b;
a=a-b;
printf("\n\nNew sequence: ");
printf("\na = %d \nb = %d", a, b);
getch();
}
#include <conio.h>
void main() {
int a=10, b=15;
clrscr();
printf("Old sequence: ");
printf("\na = %d \nb = %d", a, b);
a=a+b;
b=a-b;
a=a-b;
printf("\n\nNew sequence: ");
printf("\na = %d \nb = %d", a, b);
getch();
}
Post a Comment