![]() |
| | #1 |
| Registered User Join Date: Jul 2009
Posts: 3
| i was doing this quiz Cprogramming.com - Tutorials - C++ Programming Quiz - Loops the first answer should be B.9, shouldn't it?? i executed this ..after inserting cout<<x<<endl; and the last value was 9...how come the answer is 10? thanks |
| eViLrAcEr is offline | |
| | #2 |
| Webhead Join Date: Jul 2009
Posts: 278
| Note: This quiz question probably generates more email to the webmaster than any other single item on the site. Yes, the answer really is 10. If you don't understand why, think about it this way: what condition has to be true for the loop to stop running? |
| Spidey is offline | |
| | #3 |
| Registered User Join Date: Jun 2009 Location: Adeliade, AU
Posts: 128
| It will be 10 as the final result. 9 is smaller than 10 there fore it will be increased by 1 (x++) Now x = 10 therefore the loop will break |
| Aliaks is offline | |
| | #4 | |
| Registered User Join Date: Jul 2009
Posts: 3
| Quote:
hmm...didnt think of it like that before. x would have to be = 10 finally i guess thanks | |
| eViLrAcEr is offline | |
| | #5 | |
| Webhead Join Date: Jul 2009
Posts: 278
| Quote:
If you always rely on others to answer your questions, you will never learn. Try giving it a thought first. | |
| Spidey is offline | |
| | #6 | |
| Registered User Join Date: Jul 2009
Posts: 3
| Quote:
and i meant, more free than the webmaster and i did give a thought but i didnt understand the question properly | |
| eViLrAcEr is offline | |
![]() |
| Tags |
| noob, tutorial |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Question 26 Answer seems wrong on site quiz | Kleid-0 | C++ Programming | 2 | 04-16-2005 03:03 PM |
| whats wrong with this? no errors but wrong result | InvariantLoop | C Programming | 6 | 01-28-2005 12:48 AM |
| Problem with input choice... Somethings wrong... really wrong.... | greenferoz | C++ Programming | 9 | 07-15-2004 03:30 PM |
| God | datainjector | A Brief History of Cprogramming.com | 746 | 12-22-2002 12:01 PM |
| Half life Problem which I am right and the teacher is wrong | Shadow12345 | A Brief History of Cprogramming.com | 13 | 11-06-2002 04:28 PM |