Hello, I need some help with the program below.

#include <stdio.h>

float get_startingbalance(void);
float getCntOfWithdrawls();
float getCntOfDeposits();
float getEachDeposit();
float getEachWithdrawl();
float checkBalance();
float calcAndDisplayBalance();
float displayBankRecord();
void print_withdrawalnumber(int num_withdrawals);
void print_depositnumbers(int num_deposits);
void print_startingbalance(float start_balance);
void print_endbalance(float current_balance);

int main()
{
 /* Declare Variables */
 int num_withdrawals, num_deposits, x;
 float deposits[50] = {0.0}; 
 float withdrawals[50] = {0.0}; 
 float current_balance = {0.0};
 float start_balance = {0.0};
 char first_name[20];

 /* Output initial greeting */
 printf("Welcome to the Sears Banking System.\n");
 printf("Please enter your first name: ");
 scanf("%s", first_name);
 fflush(stdin);
 printf("\nHello, %s\n\n", first_name);

 /* Prompt user for current balance. */

 start_balance = get_startingbalance();

 printf("You entered %.2f ", start_balance);

 getchar();



} /* end main */
/*START FUNCTION GET STARTING BALANCE*/

float get_startingbalance()
{
 float start_bal;
 do
 {
  printf("Please enter your current balance in dollars and cents: ");
  scanf("%f", &start_bal);
  fflush(stdin);
  if(start_bal < 0)
  printf("Invalid entry. Starting balance must be at least zero!\n\n");
 }while(start_bal < 0); /*END DO WHILE*/

return start_bal;

} /* end function get starting balance */
/*START FUNCTION GET NUMBER OF WITHDRAWLS*/

float getCntOfWithdrawals()
{
 float num_withdrawals;
 do
 {
  printf ("\nEnter the number of withdrawals: ");
  scanf ("%d",&num_withdrawals);
  fflush(stdin);
  if (num_withdrawals < 0 || num_withdrawals > 50)
  printf ("Error: Number of withdrawals must be between zero and 50, please re-enter!\n\n");
 } while (num_withdrawals < 0 || num_withdrawals > 50); /* end do-while trap loop */

return num_withdrawals;

}/* end function number of withdrawls */
/*START FUNCTION GET NUMBER OF DEPOSITS*/

float getCntOfDeposits()
{
 float num_deposits
 do
 {
  printf ("\nEnter the number of deposits: ");
  scanf ("%i",&num_deposits);
  fflush(stdin);
  if ( num_deposits < 0 || num_deposits > 50)
  printf ("Error: Number of deposits must be between 0 and 50, please re-enter!\n\n");
 }while (num_deposits < 0 || num_deposits > 50); /* end do-while trap loop */
  
return num_deposits;

}/* end function number of deposits */
/*START FUNCTION GET EACH DEPOSIT*/

float getEachDeposit()
{
 float num_deposits
 for (x = 1; x <= num_deposits; x++)
 {
  do
    {
     printf ("Enter the amount of deposit #%i: ", x);
     scanf ("%f",&deposits[x]);
     fflush(stdin);
     if (deposits[x] <= 0)
     printf ("*** Deposit amount must be greater than zero. Please re-enter! ***\n");
    } while (deposits[x] <= 0);
  total_deposits = total_deposits + deposits[x];
}/*end for loop*/
/*end function get each deposit*/
/*START FUNCTION GET EACH WITHDRAWL*/

float getEachWithdrawl()
{
 float num_withdrawls
 for (x = 1; x <= num_withdrawals; x++)
 {
  do
  {
   printf ("Enter the amount of withdrawal #%i: ", x);
   scanf ("%f",&withdrawals[x]);
   fflush(stdin);
   if (withdrawals[x] > current_balance)
   printf ("***Withdrawal amount exceeds current balance.***\n");
   else
   if (withdrawals[x] <= 0)
   printf ("*** Withdrawal amout must be greater than zero. Please re-enter! ***");
  } while (withdrawals[x] > current_balance || withdrawals[x] <= 0); /* end do-while loop */
 total_withdrawals = total_withdrawals + withdrawals[x];
/*end function get each withdrawl*/
/*START FUNCTION CHECK BALANCE*/

float checkBalance();
{
 float current_balance
 balance = current_balance - total_withdrawals + total_deposits;
 if (balance == 0)
 {
  printf ("\n *** Balance is now zero. No more withdrawals can be made at this time. ***\n");
  num_withdrawals = x;
  break;
 } /*end-if*/
} /*end for loop*/
/*end function check balance*/
/*START FUNCTION CALC AND DISPLAY BALANCE*/

float calcAndDisplayBalance()
{
 printf ("\n*** Your closing balance is $%.2f, %s*** \n", balance, first_name);
 if (balance >= 5000.00)
 printf ("*** Time to invest some money!*** \n\n");
 else if (balance >= 15000.00 && balance <= 49999.99)
 printf ("*** Maybe you should consider a CD.*** \n\n");
 else if (balance >= 1000.00 && balance <= 14999.99)
 printf ("*** Keep up the good work.*** \n\n");
 else
 printf ("*** %s, your balance is getting low!*** \n\n", first_name);
}/*end-if*/
/*end function calc and display balance*/
/*START FUNCTION DISPLAY BANK RECORD*/

float displayBankRecord()
printf ("     *** Bank Record ***\n");
printf ("\nStarting Balance:$   %13.2f\n\n", current_balance);
for (x = 1; x <= number_of_deposits; x++)
{
 printf ("Deposit #%i:          %13.2f\n", x, deposits[x]);
}
for (x = 1; x <= number_of_withdrawals; x++)
{
 printf ("\nWithdrawal  #%i:      %13.2f", x, withdrawals[x]);
}
printf ("\n\nEnding Balance is:$  %13.2f\n", balance);
/*end function display bank record*/

The program is supposed to use functions to perform some simple banking transactions. I am pretty new to programming and I am hoping someone can point me in the right direction. Thanks in advance.

> I need some help with the program below.
Such as?
Does it compile? If not, what are the error messages.
Does it run? If not, what input did you provide, and what incorrect output did you see.

> The program is supposed to use functions to perform some simple banking transactions.
I see functions, so you're good on that front.

My problem is that I get an error message saying "syntax error at end of input" on line 194.
I can't figure out the problem so I thought I'd ask someone who is more familiar with C programming.

#include <stdio.h>
#include <conio.h>

int main(void)
{       
    
        /* Declare Variables */
        /* -------------------- */

    int x, number_of_deposits, number_of_withdrawals;
    float deposits[50], withdrawals[50];
    float current_balance;
    float balance;
    float total_deposits = 0, total_withdrawals = 0;
    float promptCurrBal();
    float promptNumWithdrawals();
    float promptNumDeposits();
    float promptAmountDeposits();
    float calcDisplay();
    char first_name[20];
    
        /* Output initial greeting */
        /* ------------------------*/
        
    printf("Welcome to the Sears Banking System.\n\n");
    printf ("Please enter your first name: ");
    scanf ("%s", first_name);
    fflush(stdin);
    printf("\nHello, %s.\n\n", first_name);   
        
        
        /* Prompt user for current balance in dollars and cents. */
        /* ----------------------------------------------------- */

promptCurrBal();
{
  do
  {
    printf ("Please enter your current balance in dollars and cents: ");
    scanf ("%f",&current_balance);
    fflush(stdin);

    if (current_balance < 0)
    printf ("Error: Beginning balance must be at least zero, please re-enter!\n\n");
  } while (current_balance < 0); /* end do-while loop */

}

        /* Prompt user for the number of withdrawals */
        /* ----------------------------------------- */

promptNumWithdrawals();
{
  do
  {
    printf ("\nEnter the number of withdrawals: ");
    scanf ("%i",&number_of_withdrawals);
    fflush (stdin);

    if (number_of_withdrawals < 0 || number_of_withdrawals > 50)
    printf ("Error: Number of withdrawals must be between zero and 50, please re-enter!\n\n");
   } while (number_of_withdrawals < 0 || number_of_withdrawals > 50); /* end do-while trap loop */
}

        /* Prompt user to enter the number of deposits. */
        /* ---------------------------------------------------- */

promptNumDeposits();
{
  do
  {
    printf ("\nEnter the number of deposits: ");
    scanf ("%i",&number_of_deposits);
    fflush (stdin);

    if ( number_of_deposits < 0 || number_of_deposits > 50)
    printf ("Error: Number of deposits must be between 0 and 50, please re-enter!\n\n");
  } while (number_of_deposits < 0 || number_of_deposits > 50); /* end do-while trap loop */
  
  printf("\n");
}

        /* Prompt user for positive deposits and withdrawals. */
        /* ---------------------------------------------------------- */

promptAmountDeposits();
{
  for (x = 1; x <= number_of_deposits; x++)
  {
    do
    {
      printf ("Enter the amount of deposit #%i: ", x);
      scanf ("%f",&deposits[x]);
      fflush (stdin);

      if (deposits[x] <= 0)
      printf ("*** Deposit amount must be greater than zero. Please re-enter! ***\n");
    } while (deposits[x] <= 0);

  total_deposits = total_deposits + deposits[x];

  }/*end for loop*/
  
  printf("\n");

  for (x = 1; x <= number_of_withdrawals; x++)
  {
    do
    {
      printf ("Enter the amount of withdrawal #%i: ", x);
      scanf ("%f",&withdrawals[x]);
      fflush (stdin);

       if (withdrawals[x] > current_balance)
       printf ("***Withdrawal amount exceeds current balance.***\n");
       else
       if (withdrawals[x] <= 0)
       printf ("*** Withdrawal amout must be greater than zero. Please re-enter! ***");
     } while (withdrawals[x] > current_balance || withdrawals[x] <= 0); /* end do-while loop */

  total_withdrawals = total_withdrawals + withdrawals[x];
  
        /* If balance goes to zero, reset the withdrawal count */
       /* --------------------------------------------------- */

  balance = current_balance - total_withdrawals + total_deposits;
  if (balance == 0)
  {
    printf ("\n *** Balance is now zero. No more withdrawals can be made at this time. ***\n");
    number_of_withdrawals = x;
    break;
  } /*end-if*/

  } /*end for loop*/
}
		
      /* Calculate and display the closing balance */
      /* ----------------------------------------------- */

calcDisplay();
{
   printf ("\n*** Your closing balance is $%.2f, %s*** \n", balance, first_name);

   if (balance >= 5000.00)
   printf ("*** Time to invest some money!*** \n\n");
            else if (balance >= 15000.00 && balance <= 49999.99)
   printf ("*** Maybe you should consider a CD.*** \n\n");
            else if (balance >= 1000.00 && balance <= 14999.99)
   printf ("*** Keep up the good work.*** \n\n");
             else
   printf ("*** %s, your balance is getting low!*** \n\n", first_name);

        /* Display bank record */
        /* ----------------------- */
	
    printf ("     *** Bank Record ***\n");

     printf ("\nStarting Balance:$   %13.2f\n\n", current_balance);

     for (x = 1; x <= number_of_deposits; x++)
         {
           printf ("Deposit #%i:          %13.2f\n", x, deposits[x]);
          }

     for (x = 1; x <= number_of_withdrawals; x++)
         {
           printf ("\nWithdrawal  #%i:      %13.2f", x, withdrawals[x]);
         }


   printf ("\n\nEnding Balance is:$  %13.2f\n", balance);

    {
     getch();
     return 0;
    }
}/*end main*/

> /*end main*/
If this really is the end of main, then all your functions are inside main, which is wrong. C doesn't have nested functions.

The next problem is you have ; at the end of what looks like your attempt to declare a function.

This is what it should look like

void calcDisplay(void);  // this is a prototype, ending in a ;

int main ( ) {
  // some code
  return 0;
}

void calcDisplay(void) // NO ; on this line
{
   printf ("\n*** Your closing balance is $%.2f, %s*** \n", balance, first_name);
   // more code
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.