My version of the Do While Loop. (May help some!)

Hello!
I wanted to show how I wrote my code in the “Do While Loop” (Section 2, Lecture 21) for the challenge part of the video.
I see that Ben did his slightly different. I wanted to show you guys an example of my working code that might also help!

If you guys see anything that might be a concern with the format of this code, let me know! I am not new to coding per say, because I have done some JavaScript. But I am new to C++ and always willing to learn new things. Feedback is much appreciated.

Thanks @ben for making such clear and knowledgeable videos. I’m loving the course! :smile:

Just a little tip, if you’re checking the value of a boolean, you don’t need to do == true. You can just do while (AskToPlayAgain()) (or (!AskToPlayAgain()) for the opposite effect).

Thanks for the tip!
I know that the (!) means something similar to “Not”, so I’ll remember that in the future. :smiley:

You’re so welcome!

@ben

So are there any problems, inconveniences or reasons of why to do it this way vs. the code shown in the course video? I also came up with this solution but without the ‘== true’ part.

This solution is fine.

Privacy & Terms