Well, here's a repaired version --
The main problem is that you can't call an earlier function and think that you're "starting over" ... you're going to return from that function, and then you get unexpected recursive side-effects. (Recursion is something to do on purpose or not at all.) [edit: actually I'm not so sure that the problem is related at all to recursion ... I'm still looking it over.] To solve that I kludged a loop in main() and added "fail" values to your functions. You should always return something when it's not a void function anyway.
I also didn't think the do...while's were very clear or efficient. Of course, you don't need to change those, I just provided an option.
Code:
#include <stdio.h>
double Get_Credit_Limit(void);
double Get_Acc_Bal(double);
int
main (void)
{
double returned_credit_limit = 0,
returned_account_balance;
while (1)
{
if ((returned_credit_limit = Get_Credit_Limit()) == 0)
continue;
if ((returned_account_balance
= Get_Acc_Bal (returned_credit_limit)) == 0)
continue;
break;
}
printf ("\nBalance: $%.2f ... Limit: $%.2f\n\n",
returned_account_balance, returned_credit_limit);
return 0;
}/*---- end of main -----------------------------------*/
double
Get_Credit_Limit (void)
{
int validate = 0;
double credit_limit = 0;
while (validate < 2)
{
printf("\nPlease enter the credit limit: ");
scanf("%lf", &credit_limit);
if ((credit_limit >= 500) && (credit_limit <= 20000))
return credit_limit;
printf ("\nMust be above 500 and less than 20000. "
"Try again\n");
++validate;
}
printf("\nERROR: Too many errors, starting new customer.\n\n");
return 0;
}/*---- end of Get_Credit_Limit ------------------------------*/
double
Get_Acc_Bal (double returned_credit_limit)
{
double account_balance;
int validate = 0;
while (validate < 2)
{
printf("\nPlease enter your account balance: ");
scanf("%lf" , &account_balance);
if (account_balance < 0)
{
++validate;
printf("\nERROR: Balance cannot be negative. Try again.\n");
continue;
}
if (account_balance > returned_credit_limit)
{
printf("\nERROR: Account balance too high, "
"starting new customer.\n\n");
return 0;
}
if ((account_balance > 0)
&& (account_balance < returned_credit_limit))
return account_balance;
}
printf("\nERROR: Too many errors, starting new customer.\n\n");
return 0;
}