I have a small program that which is confusing me. I am trying using a loop to take input from user. In case input is wrong, it is repeated again but if it is right, it exits.
You want
do
{
} while (condition);
As your forgot the semicolon, you get:
do
{
....
}
while(condition)
do something else;
You could have noticed that just by auto-indenting your code in an editor like I did on your question.
Also when you do some scanf
you should rather include the \n
in the format specification.