#something wrong in do while loop please correct this
36 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
if i input value greater than 100 it prints "invalid grade" as well as "you have entered a valid grade %d"
can you simulate on your head or pen/paper or with a debugger what is happenning when user enters 6453?
like step by step of the program flow from top to bottom
then i think you'll see why
the printf in while statement will only run if condition in while satisfy right? which is grade must be >0 and < 100?
do you mean the one on line 10 or which
line 9
that while governs when the do-while loop runs or exits yeah
my question is why it prints invalid grade as valid grade the last line in output?
the printf on line 10 is outside the do-while loop's block
it will run when the loop exists
it is unconditional
oh how do i fix this
well delete that printf? :p
but you want to say "that was valid" on valid inputs?
i see
after user enters the grade you are checking if it was invalid right?
then printing "invalid grade"
if it is not invalid, i.e., if that if statement's condition is not satisfied, then it is valid grade
yes
so what goes together with if to say "otherwise"?
else, isn't it
if (grade_is_good)
print("ok")
else
print("bad")
^pseudocode, not valid C code at the moment
cool
np
@thin path Has your question been resolved? If so, type !solved :)