Tuesday, January 22, 2013

C Language Example # 09 Swap two integer number with the use of temporary variable

C Language Example # 09 Swap two integer number with the use of temporary variable.

Lets swap two number with the use of temporary variable

C Language Code:

//Written by Latest Technology Guide    
//Title : Example 09 : Swap two integer number with the use of temporary variable

#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int a,b,c;

printf("Enter Value of A :");
scanf("%d",&a);
printf("Enter Value of B :");
scanf("%d",&b);

c=a;
a=b;
b=c;

printf("\nValue of A : %d",a);
printf("\nValue of B : %d",b);

getch();
}

Output:

We think there is no need of Output for this program.

--------------------------------------------------------------------------------
Explanation of C Language Example # 09 Swap two integer number with the use of temporary variable..

* Enter Number A and B.
* Program will swap this number and will display.

Note: All programs are developed and tested using Turbo C++ 3.0 under Windows XP. We just want to provide guidelines to the users. If you are using any other Compiler or other operating system they you need to modify this program as per your requirements. 

1 comment: