Quantcast
Channel: Comments on: 6.3 — Arrays and loops
Browsing latest articles
Browse All 372 View Live

By: DeveloperInDevelopment

My solution to Question 2 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 #include <iostream> int getInt(){    while (true){        std::cout << "Enter...

View Article



By: JBR

12345678910111213141516 int getNumber(){    int number{0};    do    {        std::cout << "Enter an integer between 1 and 9" << '\n';        std::cin >> number;//      std::cout...

View Article

By: nascardriver

Line 12 and 15 are unconditional. They should be outside of the `if`. The 9 in line 23 doesn't do anything apart from confusing the caller of your function. `array` can have any size. Otherwise good...

View Article

By: nascardriver

If you enter "11.5", the "11" gets extracted and extraction stops at ".", because "." is not a valid character for integer extraction. Your loop loops, because line 14 is true. ".5" is left in the...

View Article

By: JBR

Oh that makes a lot of sense. So when i enter something like 4.5, the 4 gets extracted but the while loop is exited. Thanks for the clarification. Thanks also for the website and keep up the great work!

View Article


By: CC

In your solution to Q2, when running the compiled program in a shell, pressing CTRL-D (which I believe sends an EOF character) results in the program running an ostensibly infinite loop. (In my...

View Article

By: nascardriver

Supposedly `std::cin` can be reused after receiving an EOF, but I couldn't get it to work. I don't think it's a good idea to reuse the stream after it reached EOF. Instead, I'd stop the program. You...

View Article

By: Sv3n

Hey Guys, Not sure how to reach you otherwise, but, there is an app in Windows Store called Master C++ which is a copy-paste of this website. Just FYI. Thx for your grate job.

View Article


By: yeokaiwei

Quiz 1,2 Interesting, you can't just a. use sizeof() in the loop E.g. for (int i = 0; i < sizeof(array) ; i++) b. use intialize an integer using sizeof() E.g. for (int i = 0; i < x ; i++) c  use...

View Article


By: yeokaiwei

Quiz 3 Feedback. I got confused with the question for maxIndex. Due to the enum() examples, I thought you wanted us to add a variable to the end of the array called maxIndex e.g.  int scores[]{ 84, 92,...

View Article
Browsing latest articles
Browse All 372 View Live




Latest Images