Can someone explain to me how to do practice question 5.2? | Sololearn: Learn to code for FREE!


Can someone explain to me how to do practice question 5.2?

I don't how to swaw the value in the variables

10/22/2021 8:43:58 PM

Jonathan Hurst

9 Answers

New Answer


Jonathan Hurst , can you please mention the tutorial / programming language? => before we can help you, you should show us your attempt first. if you have not done a try by yourself upto now, please do so. put your code in playground and link it here. thanks!


Which programming language? Can you please put it in the tags?


the langauge is C++


I dont know how to put my code in plgaground and link it here


i saved my attempt, how do i find my saved coding?



is that right?


Jonathan Hurst You were on the right track when you introduced a third tank, but your syntax got a bit messy after that. I fixed your code, read through it and you will understand the importance of re-assigning the value of a variable #include <iostream> using namespace std; int main() { int aquariumDavid = 8; int aquariumAlex = 11; int complexaqurium = 0; // your code goes here complexaqurium = aquariumDavid; aquariumDavid = aquariumAlex; aquariumAlex = complexaqurium; cout << "David's aquarium: " << aquariumDavid << endl; cout << "Alex's aquarium: " << aquariumAlex; return 0; }


change complex to 8 change david to 11 change alex to complex(8) So, i think i get it. You first put David into complex. Then you put alex into david. Then you put complex( which you put David into) into Alex. which would turn it into David. Correct?