Can someone explain to me how to do practice question 5.2? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

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

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

22nd Oct 2021, 8:43 PM
Jonathan Hurst
9 Answers
+ 7
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!
22nd Oct 2021, 8:47 PM
Lothar
Lothar - avatar
+ 2
Which programming language? Can you please put it in the tags?
22nd Oct 2021, 8:48 PM
Lisa
Lisa - avatar
+ 1
the langauge is C++
22nd Oct 2021, 9:11 PM
Jonathan Hurst
0
I dont know how to put my code in plgaground and link it here
22nd Oct 2021, 9:10 PM
Jonathan Hurst
0
i saved my attempt, how do i find my saved coding?
22nd Oct 2021, 9:13 PM
Jonathan Hurst
22nd Oct 2021, 9:19 PM
Jonathan Hurst
0
is that right?
22nd Oct 2021, 9:19 PM
Jonathan Hurst
0
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; }
22nd Oct 2021, 11:13 PM
Rik Wittkopp
Rik Wittkopp - avatar
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?
25th Oct 2021, 8:17 PM
Jonathan Hurst