943,746 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 436
  • C++ RSS
Dec 9th, 2008
-1

What is do?

Expand Post »
26. What is printed in the following code segment?
   I = 1;
      do
      {
      I = I + 25;
      }
      while ( I > 50 );
      cout << I + 50;
a) 50
b) 51
c) 75
d) 76
Reputation Points: 5
Solved Threads: 0
Newbie Poster
Awebb999 is offline Offline
14 posts
since Dec 2008
Dec 9th, 2008
0

Re: What is do?

do is the top of a loop
C++ Syntax (Toggle Plain Text)
  1. do {
  2. // something here
  3. } while ( <some condition here that stops the loop> );

I'm not going to answer the question you posted -- write a small test program and see for yourself what the answer is. Just post that code in a main() function and you have it done.
Last edited by Ancient Dragon; Dec 9th, 2008 at 2:29 am.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Dec 9th, 2008
0

Re: What is do?

23 http://www.daniweb.com/forums/thread161397.html
14 http://www.daniweb.com/forums/thread161389.html
Is this a live feed direct from my keyboard to your answer sheet without going through YOUR mind?
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Dec 9th, 2008
0

Re: What is do?

; it will print out "76"
; do means an action will happen and then it will check if the while ;statement is true, if so again it will go to do or else it will exit from ;do while loop
I = I + 25; // it will add 25 to I
while ( I > 50 ); // then it will check if I is more than 50, if so it will again add 25 to I
else
it will print I out.
Reputation Points: 40
Solved Threads: 4
Junior Poster in Training
low_coder is offline Offline
55 posts
since Nov 2008
Dec 9th, 2008
0

Re: What is do?

umm no i'm trying to study for my exam tom. and i just wanted to justify that i'm doing this right....this is my practice exam she gave us to study with thanks...
Reputation Points: 5
Solved Threads: 0
Newbie Poster
Awebb999 is offline Offline
14 posts
since Dec 2008
Dec 9th, 2008
0

Re: What is do?

Practice problems mean you type them into your compiler, compile them, and see how they work. That's the best way to figure out how things work. For these, forget the internet -- pretend it doesn't exist. All you have is you, your computer, and your compiler.
Last edited by Ancient Dragon; Dec 9th, 2008 at 2:52 am.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: pointersq
Next Thread in C++ Forum Timeline: Can someone tell me if I did these links correctly?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC