C++ program to swap two numbers without using third variable (hindi) - Computer Education

This blog about the basic knowledge of computer and all other topics related to it.

computereducation

Sunday 11 March 2018

C++ program to swap two numbers without using third variable (hindi)

wap to swap two numbers without using third variable in c++

       C++ program to swap two number is a interesting program.c++ has many programms but this program is something unique from other program.Follow the c++ codings bellow to interchange the two variable value that means if the valiue of a=10 and the value of b=20 then after the interchange the the value of a=20 and the value of b=10.And we have to prove this by this program.Using the turbo C++ software run trhe program given bellow and the result is that you want.If their is any errors in this program then correct it carefully.

Interchanging the variable without using the 3rd variable
C++ program to swap two numbers without using third variable (hindi)
C++ program to swap two numbers without using third variable (hindi)
Interchanging the variable without using the 3rd variable

#include<iostraem.h>
#include<conio.h>

class swap
{
private
int;
int;
public:

void getdata()
{
cout<<"Enter the value of a:";
cin>>a;
cout<<"Enter the value of b:";
cin>>b;

}

void interchange()

{
a=a+b;
b=a-b;
a=a-b;

}
void pudata()

{

cout<<"value of a="<<a<<endl;
cout<<"value of b<,b<,endl;

    }
};

void main()
{
clrscr();

swap s1;
s1.getdata();

cout<,"before interchange"<,endl;
cout<<"-------------------"<<endl;
s1.putdata()(;
getch(0;

}

out put:
After interchange/swap the value of a become the value of b and the vice versa.






Related programs:
1.C++ program to swap two numbers  using third variable (hindi)
2.program for both data member and membert function as public
3.c program to check whether the number is palidwomic or not

for more program click here

Email id:akashkumarswain14@gmail.com

No comments:

Post a Comment

Thanks for join with us.