C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28629
Number of posts: 94611

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Where's the input query in this code?? Posted by Ulnarian on 8 Jun 2006 at 9:19 PM
Hey all, I'm kinda new at this whole programming thing. Anyways, I've got this book, and the following is a chunk of code from the book. Apparently, somewhere in here, this program asks the user to input the weight of his fish, but....I can't find it....can you tell me where its at?

Here's the relevant portion:


double fish[Max];
cout << "Enter weight.\n";
cout << "You may enter up to " << Max
<< " fish <q to terminate>.\n";
cout << "fish #1 ";
int i=0;
while (i<Max && cin >> fish[i]) {
if (++i < Max)
cout << "fish #" << i+1 << ": ";
}


Does the test condition portion of the while loop double as an input query from the user??
Report
Re: Where's the input query in this code?? Posted by Donotalo on 8 Jun 2006 at 9:39 PM
: Hey all, I'm kinda new at this whole programming thing. Anyways, I've got this book, and the following is a chunk of code from the book. Apparently, somewhere in here, this program asks the user to input the weight of his fish, but....I can't find it....can you tell me where its at?
:
: Here's the relevant portion:
:
:
: double fish[Max];
: cout << "Enter weight.\n";
: cout << "You may enter up to " << Max
: << " fish <q to terminate>.\n";
: cout << "fish #1 ";
: int i=0;
: while (i<Max && cin >> fish[i]) {
: if (++i < Max)
: cout << "fish #" << i+1 << ": ";
: }
:
:
: Does the test condition portion of the while loop double as an input query from the user??
:
look at the while condition, there is a cin statement which is taking the input.


~Donotalo()

Report
Re: Where's the input query in this code?? Posted by Ulnarian on 8 Jun 2006 at 11:00 PM
Thanks, I just didn't know that the expression test portion of a while loop could also double as an input query :)


: : Hey all, I'm kinda new at this whole programming thing. Anyways, I've got this book, and the following is a chunk of code from the book. Apparently, somewhere in here, this program asks the user to input the weight of his fish, but....I can't find it....can you tell me where its at?
: :
: : Here's the relevant portion:
: :
: :
: : double fish[Max];
: : cout << "Enter weight.\n";
: : cout << "You may enter up to " << Max
: : << " fish <q to terminate>.\n";
: : cout << "fish #1 ";
: : int i=0;
: : while (i<Max && cin >> fish[i]) {
: : if (++i < Max)
: : cout << "fish #" << i+1 << ": ";
: : }
: :
: :
: : Does the test condition portion of the while loop double as an input query from the user??
: :
: look at the while condition, there is a cin statement which is taking the input.
:

:
~Donotalo()
:
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.