Validate input for the following condition
I came across a question which takes float as input the rest of question
was followed by it. It had a validation such that we take input float k
and check if the input lies between 10 and 100 otherwise if the input is
outside it again take input. The rest of question followed this value of k
which was easy to solve. But the real problem which i got was the
validation i just put the condition
scanf("%f",&k);
if(k>10.0 && k<100.0)
scanf("%f",&k);
else
{
......//my code
}
But when i submitted it it gave wrong answer the real problem was at the
#Input-10.@
#Input-@
because for this input it rather than going to else part went to if part
though the input like
#Input-10
was satisfied. Can anyone give me solution to this problem where the input
of float and integer type within this range are only satisfied otherwise
not. Regards before
No comments:
Post a Comment