### Beginner Exercises

Pages: 123456... 16
British? I'm in Washington! =P

Anyway, when in doubt, check urbandictionary.com
Thanks for this guys, I am very new to programming and these have helped me a lot. I have only done two of them but will work on the rest of them tonight.

P.S. The DP this is awesome, I'm sure that guy's mom would not like it very much. lol
Here we go again...
 Anyway, when in doubt, check urbandictionary.com

No thank you I just ate ....
Suffice it to say that if your parents ever mention a "third wheel," you should cover your ears.
Last edited on
i have a question on the bunnies exercise. what if there is 2 male adult bunnies and 3 female adult bunnies. does that mean that 6 new bunnies is created? or there should only be 3 bunnies created?

anyone here who have finish this exercise?
This is from the exercise text:
 So long as there is at least one male age 2 or older, for each female bunny in the list age 2 or older; a new bunny is created each turn
@Bazzy
so in my example of 2 male and 3 female (assuming there atleast age of 2) there will be 2 bunnies to be created?
Each female has one child
ok, thanks. sorry i dont understand english that good.
 Suffice it to say that if your parents ever mention a "third wheel," you should cover your ears.

*cough**cough*ackassjay*cough**cough*
Har-har
Last edited on
Sorry I'm late.

chrisname wrote:
I love me some DP.
DrChill wrote:
My mom loves DP
HAHAHAHAHAHAHAHAHAHAHAHA!
Last edited on
 Sorry I'm late.

You're almost a month late.

 HAHAHAHAHAHAHAHAHAHAHAHA!

Many hands make light work...
Birds of a feather fly together.
Thanks, very useful for me.

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950`` ``````#include int main() { int score; do { std::cout<<"Please input your score:"; std::cin>>score; switch (score/10) { case 10: std::cout<<"You get the A , Congratualations!\n"<

closed account (S6k9GNh0)
A couple of problems:

`#include <IOStream> `
This may not be problematic but the correct spelling of the header file is iostream all lowercase.

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243`` `````` do { std::cout<<"Please input your score:"; std::cin>>score; switch (score/10) { case 10: std::cout<<"You get the A , Congratualations!\n"<

Have you run your code? This code will never stop. So that means when your user gives you input, it will give output and immediately ask for input again. In any program, you want it to stop at some point in time.

Also, there is no need for the do-while loop here. To reduce your code and confusion, you would just use a while loop. The use of a do-while loop is when you need the code to be executed at least once before the boolean placed in the while function is checked. As (1) always return true, there should be no problem with this. ALSO, if you were to do that, instead of using while(1), I would use for(;;) which is a quick optimization boost as while(1) actually uses instruction to check and see if 1 is true where as the latter does not.

I also posted a version of the example earlier in this same topic. It DOES use a loop and you can look at it as an example on how to do it more correctly.
Last edited on
 I would use for(;;) which is a quick optimization boost as while(1) actually uses instruction to check and see if 1 is true where as the latter does not.

Umm... what?

while(1) is fine
Because the compiler couldn't possible figure out that while (1) can be compiled to a simple unconditional jump. I mean, while (1) is so rarely used, that the developers couldn't possibly think of that one.
@computerquip : Thanks, I ran my code and I stop it with Ctrl+C. and I added "do ... while" for convenience of debugging. I read your code and it help me a lot. I remain my code here and let guys discuss the wrong example.
Pages: 123456... 16