Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,207,947 members, 8,000,891 topics. Date: Tuesday, 12 November 2024 at 05:20 PM |
Nairaland Forum / Science/Technology / Programming / Someone Please Put Me Through This (C++) PICS (628 Views)
Omo E Be Like Sey I Go Dump This C++ For Yahoo Ooh, Which One Be Binary Again? / Please Guys Help Me With This C++ Program Exam Question. It's Urgent. (2) (3) (4)
Someone Please Put Me Through This (C++) PICS by TastyFriedPussy: 12:12pm On Nov 11, 2022 |
Someone please put me through this... Long story short, it's a programme that doesn't end until the user want's it to end(using a while loop) Where I'm having challenges is the condition in the while loop and the last else if statement... For instance 1 Like
|
Re: Someone Please Put Me Through This (C++) PICS by TastyFriedPussy: 12:17pm On Nov 11, 2022 |
Where I'm having issues understanding is from that condition In the while loop and the last else if statement.. We've already made done equal to true in the while loop condition by doing this (!done)... So why still go to the last else if to make done = true? For instance, if I change the condition in the while loop to (done or done = true) the programme would run but it'll ignore all the statements in the while loop and exit straight... Same happens if I change the last else if to be false Why? 1 Like |
Re: Someone Please Put Me Through This (C++) PICS by Nobody: 12:31pm On Nov 11, 2022 |
Coconut head |
Re: Someone Please Put Me Through This (C++) PICS by chukwuebuka65(m): 1:33pm On Nov 11, 2022 |
GREATIGBOMAN: He never see anything. |
Re: Someone Please Put Me Through This (C++) PICS by qtguru(m): 1:42pm On Nov 11, 2022 |
|
Re: Someone Please Put Me Through This (C++) PICS by TastyFriedPussy: 3:08pm On Nov 11, 2022 |
qtguru:that was just a joke bro, most of what I say here are just jokes and just for attention... Please help. |
Re: Someone Please Put Me Through This (C++) PICS by chukwuebuka65(m): 3:27pm On Nov 11, 2022 |
TastyFriedPussy: Mr man stop writing supergetti code. If you don’t want your loop to complete after you set your Boolean to true, you have to break out from the loop. |
Re: Someone Please Put Me Through This (C++) PICS by TastyFriedPussy: 4:13pm On Nov 11, 2022 |
chukwuebuka65:it seems you don't understand... That program is one that doesn't end except the user want's it to. I didn't write the code myself, I don't just understand the condition in the while loop and the last else if statement... Firstly a boolean named "done" is assigned the value "true", then a while loop is declared stating that " while (!done)" which to me translates to "while(done = true )"..... Then proceeds to writing the loop body...... But what's confusing me now is if you check the last else if statement, you'll see that of the user inputs "3" , then "done = true" that's the block that ends the programme with the users input... But my question is, since we've already made done equal to true in the loop condition by doing this "while (!done)", how does the programme end? That's just what's confusing me.. 1 Like |
Re: Someone Please Put Me Through This (C++) PICS by TastyFriedPussy: 4:17pm On Nov 11, 2022 |
@qtguru |
Re: Someone Please Put Me Through This (C++) PICS by TastyFriedPussy: 4:17pm On Nov 11, 2022 |
Honestly, I'll find it hard to move on if I can't grasp this |
Re: Someone Please Put Me Through This (C++) PICS by qtguru(m): 4:43pm On Nov 11, 2022 |
TastyFriedPussy: Read while loops or watch youtube, no rush you will get it. |
Re: Someone Please Put Me Through This (C++) PICS by chukwuebuka65(m): 5:00pm On Nov 11, 2022 |
TastyFriedPussy: Doing “!done” doesn’t set variable “done” to true. It only returns the opposite of the value of “done”. It is not the same as “done = true”. If you do that , the loop may not run at all because the statement is just setting the value to true and is not returning either true or false to the while loop so the while loop can know whether to run or not. Statements inside “while “ loop conditions or “if” statement conditions should return either true or false. Since “done” is false, “!done” will return true to the while loop , so that it executes the code inside, but “!done” doesn’t set the value of “done “ to the opposite of the current value. Remember “done = true” is not the same as “done == true”. 1 Like 1 Share |
Re: Someone Please Put Me Through This (C++) PICS by TastyFriedPussy: 5:12pm On Nov 11, 2022 |
Re: Someone Please Put Me Through This (C++) PICS by eventainment(m): 5:29pm On Nov 11, 2022 |
TastyFriedPussy:The while loop runs infinitely if it's condition is true. Basically the code will run forever till you select the third condition and that will change the variable condition and stop the loop |
(1) (Reply)
How Do I Start My Own Cybersecurity Firm / Paid Moderator Recruitment For Programming Board [Closed] / Programming With Vb.net
Viewing this topic: 1 guest(s)
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 29 |