Friday 31 August 2012

Swapping of two number in c++ source code

How to  swap of given number  in c++.
Logic to swap two number with cpp  code.
#include<iostream.h>
#include<conio.h>
#include<math.h>
class swap
{
int a,b,temp;   //declaration//
public:
void get();
void cal();
};

void swap::get()
{
cout<<"\n\n enter the first number=";
cin>>a;
cout<<"\n enter the second number=";
cin>>b;
}
void swap::cal()
{
temp=a;
a=b;
b=temp;
cout<<"after swapping \n\n a="<<a<<"\n\nb="<<b;
}


void main()
{
swap ob;
clrscr();
//ob.get();
ob.cal();
getch();
}
c++ | swap of given number |  program | source code
Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: