What is do?

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2008
Posts: 14
Reputation: Awebb999 has a little shameless behaviour in the past 
Solved Threads: 0
Awebb999 Awebb999 is offline Offline
Newbie Poster

What is do?

 
-1
  #1
Dec 9th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,407
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1468
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: What is do?

 
0
  #2
Dec 9th, 2008
do is the top of a loop
  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.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: What is do?

 
0
  #3
Dec 9th, 2008
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?
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 23
Reputation: low_coder is an unknown quantity at this point 
Solved Threads: 2
low_coder low_coder is offline Offline
Newbie Poster

Re: What is do?

 
0
  #4
Dec 9th, 2008
; 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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 14
Reputation: Awebb999 has a little shameless behaviour in the past 
Solved Threads: 0
Awebb999 Awebb999 is offline Offline
Newbie Poster

Re: What is do?

 
0
  #5
Dec 9th, 2008
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...
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,407
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1468
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: What is do?

 
0
  #6
Dec 9th, 2008
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.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC