I am trying to check for valid date.. if it is not valid then I ask them to reenter the date. Otherwise it should ask for the deposit. But when I enter a bad date and then reenter the date it hangs? Why?
Code:
case 1:
printf("Please enter a valid date from 1 to 31: ");
scanf("%d", &date);
if ((date < 1) || (date > 31)){
printf("Please enter a valid date from 1 to 31. ");
scanf("%d", &date);
}else
printf("How much do you want to deposit? ");
scanf("%f", &dpst);
if ( crdt == 0 ) {
blnce = strt_blnce + dpst;
} else if (crdt > 0)
blnce = blnce2 + dpst;
printf("Your current balance is $%1.2f. \n\n", blnce);
crdt++;
printf("Please indicate your option: ");
scanf("%d", &opt);
break;