mardi 24 août 2021

Why this code outputs garbage value after swapping the values?

Take two numbers as input and swap them and print the swapped values.You do not need to print anything, it has already been taken care of. Just implement the given function.And the functions looks like this.

 pair < int, int > swap(pair < int, int > swapValues) {
         int c;
         c=swapValues.first; 
         swapValues.first=swapValues.second;
         swapValues.second=c;
         cout<<swapValues.first<<" "<<swapValues.second<<"\n";
    
         }

Aucun commentaire:

Enregistrer un commentaire