Having trouble swapping values in C++ | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

Having trouble swapping values in C++

#include <iostream> using namespace std; int main() { int a = 5; int b = 9; cout << "a: " << a << endl; cout <<"b: " <<b; return 0; }

20th Dec 2020, 12:38 PM
IronCat
IronCat - avatar
1 Réponse
+ 5
Just use std::swap(a, b) to swap the values of a and b
20th Dec 2020, 12:45 PM
Aaron Eberhardt
Aaron Eberhardt - avatar