Program to Interchange numbers in C.

This program swaps the value stored in two different variables. To perform this task, third variable is declared.

 

Let’s Open turboC and write the following Code.

 

// Code:

 

#include<stdio.h>

#include<conio.h>

void main()

{

    long int  a,b,temp;

    clrscr();

    printf(“enter first number:”);

    scanf(“%li”,&a);

    printf(“enter second number:”);

    scanf(“%li”,&b);

    temp=a;

    a=b;

    b=temp;

    printf(“interchanged numbers are:\n first number is:%li”,a);

    printf(“\n second number is: %li”,b);

    getch();

}

 

 

 

Now , Run the program and see Output.

 

 

Output:

 

 

 

output

 

Happy coding.