Answer to Question #278183 in C++ for me2

Question #278183

Pointer code example



1
Expert's answer
2021-12-10T13:22:23-0500
#include <iostream>


using namespace std;


void swap(int *a, int *b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}


int main()
{
    int a, b;
    cout << "a = ";
    cin >> a;
    cout << "b = ";
    cin >> b;
    swap(&a, &b);


    cout << "a: " << a << ' ' << "b: " << b << '\n';


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog