While Loops for random numbers
Show older comments
Hi, I was given this assignment and wasn't sure how to set up the loop.
"Write a "while" loop that continues generating a random number x until x is less than 0.01. Keep track of how many iterations of the loop occurred. Then, use "fprintf" to print the final iteration count to the command window, along with the last value of x."
Thanks.
8 Comments
I recovered the removed content from the Google cache (something which anyone can do). Editing away your question is very rude. Someone spent time reading your question, understanding your issue, figuring out the solution, and writing an answer. Now you repay that kindness by ensuring that the next person with a similar question can't benefit from this answer.
Rik
on 14 Jul 2022
You're allowed to change your name in an attempt to avoid your teachers catching you for academic fraud, but removing the question text another time is not just offensive, it is also pointless. Just like your attempt to remove the question from the WayBack Machine (I'm assuming it's you who just triggered a save of this page twenty minutes ago). The whole point of the WBM is to preserve the internet. The only thing you did is make your edit even more permanent by showing you changed your name in the interim.
Feel free to appologize.
Below is your original post, which I will also paste back in the question body.
While Loops for random numbers
Hi, I was given this assignment and wasn't sure how to set up the loop.
"Write a "while" loop that continues generating a random number x until x is less than 0.01. Keep track of how many iterations of the loop occurred. Then, use "fprintf" to print the final iteration count to the command window, along with the last value of x."
Thanks.
Jeremy Hawk
on 14 Jul 2022
Fangjun Jiang
on 14 Jul 2022
A notification came up that this thread need to be moderated. I don't know why an ordinary question and answer came to this point. But in any case, please be nice to each other. No need to hold grudge. No need to write lengthy rude comments to not only impact other's emotion negatively but also to your own. Use the time to study and help others.
Rik
on 15 Jul 2022
I esplained in my inital comment why I restored the question. Then you edit away your question again. I can't see a valid reason to do so and you did not post a comment with your reason.
There is nothing wrong with asking homework questions or providing answers to them. I do take issue with people editing away their question. Do you deny any assertions I made? If you revert the edit to your question I will delete my second comment (and this one).
@Fangjun Jiang Feel free to delete all off-topic comments and revert the edit to the question. If you prefer not to, I'll contact Mathworks to step in.
John D'Errico
on 7 Aug 2022
@Jeremy Hawk - Try being civil. I removed the nasty comment from your question.
Rena Berman
on 23 Aug 2022
(Answers Dev) Restored edit
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!