A mechanical engineer confused if IF ELSE statement can do this
i have confusion. i am writing a C program for a quiz. i wanna know if we can give the user 2 tries to enter the answer. here is the simple program. please have a look.
#include <stdio.h>
int main()
{
char ans, ans2;
printf("What is the equivalent value of 0 Farenheit in Celcius?\na.) 0\nb.) -40\nc.) -17.78\n");
scanf("%c",&ans);
if (ans=='c')
{
printf("You are Smart!!!!!\n");
}
else
{
printf("You are Dumb!!!\n");
printf("Give it another try\n");
scanf("%c",&ans2);
if (ans2=='c')
{
printf("Thank God!!!!......Finally you are correct\n");
}
else
{
printf("you are the Dumbest person on Earth\n");
}}
return 0;
}