0

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";
    
         }
cigien
  • 57,834
  • 11
  • 73
  • 112
  • 3
    This code exhibits undefined behavior, by way of reaching the closing brace of a non-`void` function without encountering a `return` statement. In other words: the function promises to return a `pair`, but doesn't in fact return anything. – Igor Tandetnik Aug 24 '21 at 13:07

1 Answers1

0

Just replace the line cout<<swapValues.first<<" "<<swapValues.second<<"\n"; with return swapValues;

As stated in your question

You do not need to print anything, it has already been taken care of.

Ralf Ulrich
  • 1,575
  • 9
  • 25