Write a C program to interchange the contents of C and D

c program to interchange the value of variable
c program to interchange the value of variable

Problem Statement : 

Two numbers are input through the keyboard into two locations C and D. Write a program to interchange the contents of C and D.

Answer:
/* Interchanging of contents of two variables c & d */

#include<stdio.h>
#include<conio.h>

main()
{

int c,d,e;

clrscr();
printf(“\n Enter the number at location C:”);
scanf(“%d”, &c);

printf(“\n Enter the number at location D:”);
scanf(“%d”, &d);

/*Now interchange the contents of two variables using a third variable as temp store */

e=c;
c=d;
d=e;

printf(“\n New Number at location C=%d”,c);
printf(“\n New Number at location D=%d”,d);

printf(“\n\n\n\n\n Press any key to exit….”);
getch();

}

Satya Prakash

VOIP Expert: More than 8 years of experience in Asterisk Development and Call Center operation Management. Unique Combination of Skill Set as IT, Analytics and operation management.

Leave a Reply