OK here is a piece of my program:
Code:
#include<stdio.h>
#include<math.h>
#define PIN 2424
#define TRUE 1
/* Function Prototypes */
void bank_logo(void);
void validate_pin(void);
int get_data(int money);
int get_balance(double balance, int bal_cash);
void fifties_twenties_tens(int tot_bal, int *fifty, int *twenty, int *ten);
int main(void)
{
double open_bal;
int cash;
int new_cash;
int money;
int balance_cash;
int fif;
int twen;
int tens;
int remaining_balance;
bank_logo();
validate_pin();
printf("Enter the opening balance of your account $");
scanf("%lf", &open_bal);
printf("Enter how much cash you need? $");
scanf("%d", &cash);
balance_cash = get_data(cash);
printf("\nThe amount you are withdrawing = %d\n", balance_cash);
remaining_balance = get_balance(open_bal, balance_cash);
printf("Remaining Balance in your account = %d\n\n", remaining_balance);
printf(" *** Take your cash as $$$ bills *** \n\n");
fifties_twenties_tens(balance_cash, &fif, &twen, &tens);
printf(" %5d fifty %5d twenties and %5d tens\n\n", fif, twen, tens);
/*
printf(" %5d fifty %5d twenties and %5d tens", fifties_twenties_tens(balance_cash, &fif, &twen, &tens);
*/
return(0);
}
void validate_pin(void)
{
int id; /* input of user's PIN number */
int count;
for (count = 0; count < 3; ++count){
printf("Enter your 4-digit personal identification (PIN) >> ");
scanf("%d", &id);
if (id != PIN)
printf("Sorry! Invalid PIN number !\n");
else if (count == 3)
printf("\nYour chances are up. Better luck next time.\n\n");
else
break;
}
}
What I want it to do in function validate_pin is if the user fails to enter the the PIN number after 3 tries, I want it to print Your chances are up. Better luck next time. And then end the program. But if the enter the PIN within 3 tries to continue with the program.