Need Help with the code
Sep 3, 2014 at 11:55am Sep 3, 2014 at 11:55am UTC
What is the correct answer and why?
1 2 3 4 5 6 7 8 9
int main() {
float val = 100.0;
do {
val = val / 5;
cout << "*" ;
} while (val > 1.0);
return 0;
}
Put the code you need help with here.
Sep 3, 2014 at 12:11pm Sep 3, 2014 at 12:11pm UTC
What do you mean by correct answer?
Aceix.
Sep 3, 2014 at 12:13pm Sep 3, 2014 at 12:13pm UTC
All your program will do is print out an '*' for everytime your divide by 5 and the value is still greater than 1. So, it will print out 20 * on one line. What are you attempting to do?
Sep 20, 2014 at 4:52pm Sep 20, 2014 at 4:52pm UTC
I did it using Netbeans the answer is ***. I do not understand Why? Please help.
Sep 20, 2014 at 5:22pm Sep 20, 2014 at 5:22pm UTC
BEcause after you divide val by 5 third time result will be less than 1 and loop condition would not be met anyore so program will end.
Topic archived. No new replies allowed.