Exchange the value a=19 and b=80. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Exchange the value a=19 and b=80.

Please help me

21st Feb 2021, 4:50 PM
Ashish Kumar Nimesh
Ashish Kumar Nimesh - avatar
2 Answers
+ 5
#include <iostream> #include <tuple> using namespace std; int main() { int a = 10, b = 20; tie(a, b) = make_tuple(b, a); cout<< "Swapping values : a = " << a <<endl << "b = " << b; return 0; }
21st Feb 2021, 5:50 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
int x = b; b = a; a = x ;
21st Feb 2021, 5:06 PM
Ayush Maurya
Ayush Maurya - avatar