Swap two numbers

#include <bits/stdc++.h>
using namespace std;

// } Driver Code Ends
//User function Template for C++

void utility(int &a, int &b)
{
int temp = a;
a=b;
b=temp;
}

how the swapped values are getting printed , when we haven’t used cout

In the funtion (utility) value of a and b is swapped so, in the main (main())function when you try to print (after calling utility function) the value of a and b it is printed.

if a and b got swapped in utility , then whats the use of temp??? btw this was not my question???how the swapped values are getting printed , when we haven’t used cout

Watch this video : C Program To Swap Two Numbers using Pointers - YouTube

I hope this will clear your doubt🤞…