Answers for "swap values in array c++"

C++
3

swap values in array c++

#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
     int array[]={1, 2};
     cout<<array[0]<<" "<<array[1]<<endl;
     swap(array[0], array[1]);
     cout<<array[0]<<" "<<array[1];
     return 0;
}
Posted by: Guest on January-20-2021

Browse Popular Code Answers by Language