C++ Program to Swap to integer value.This program asks user to enter two numbers and this program will swap the value of these two numbers.
Simply use oh three variable as shown in the program a, b & temp.
external variable temp is use to hold the value of a so that it can be use to assign value to b variable.
Source Code:-
#include<iostream.h>
#include<conio.h>
void main()
{clrscr();
int a,b,temp=0;
cout<<"Program to swap two number by-Tarun Rawat\n\n";
cout<<"Enter first number (let a) : ";
cin>>a;
cout<<"\nEnter second number (let b) : ";
cin>>b;
temp=a;
a=b;
b=temp;
cout<<"\nAfter swap :- ";
cout<<"\n\t\tValue of a is : "<<a<<"\n\n\t\tValue of b is : "<<b;
getch();
}
Welcome to " way2cplusplus.blogspot.in " Objective of this blog is to implement various Computer Science Engineering Lab problems into C++ programming language. These are basically most common Lab Exercise problems based on the curriculum of engineering colleges throughout the Nation. These lab exercises are also relevant to Data structure. Simply C++ programming zone...
No comments:
Post a Comment