0

Can someone help me to create a program which take two variable and swap them with the help of a temporary variable.

#include<iostream> Using names pace std; Int main() { Int a; Cout<<"enter first number:"<<endl; Cin>>a; Int b; Cout<<"enter second number:"<<endl; Cin>>b; Int c; a = c; b = a; c = b; Cout<<"a ="<<a<<endl; Cout<<"b ="<<b<<endl; return 0; }

25th Jul 2016, 1:29 AM
himanshu ramawat
himanshu ramawat - avatar
2 Respuestas
+ 1
#include<iostream> using namespace std; int main() { int a,b,temp; cout<<"enter a and b values"; cin>>a>>b; temp=a; a=b; b=temp; cout<<" a = "<<a; cout<<" b= "<<b; return 0; }
25th Jul 2016, 7:58 AM
navya
0
c = a; a = b; b = c;
29th Jul 2016, 10:28 AM
Crystallin Roberts
Crystallin Roberts - avatar