Learn about Swap Two Number:-
Swap Two Values In C++ First of all in this program swap two number first header file include iostream then start the main function three variable declared a,b and temp variable then user enter first number then first number store in a variable then user enter the second number then second number store the b variable then formula use to swap the number.CODE:-
#include<iostream>using namespace std;
int main()
{
int a,b,temp;
cout<<"Enter the first number:";
cin>>a;
cout<<"Enter the second number:";
cin>>b;
cout<<"you input the number as"<<a<<"and"<<b<<endl;
temp=a;
a=b;
b=temp;
cout<<"The Values after swapping are"<<a<<"and"<<b<<endl;
}
OUTPUT:-
Enter the first number:30
Enter the second number:40
you input the number as 30 and 40
The Values after swapping are 40 and 30
No comments:
Post a Comment
Thanks for comment