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; }
1 Answer
+ 5
Just use std::swap(a, b) to swap the values of a and b
#include <iostream> using namespace std; int main() { int a = 5; int b = 9; cout << "a: " << a << endl; cout <<"b: " <<b; return 0; }