One tiny error.

This is a discussion on One tiny error. within the C++ Programming forums, part of the General Programming Boards category; Okay, I was able to fix 11 of the 12 errors I've been getting. I just want to get the ...

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    5

    Post One tiny error.

    Okay, I was able to fix 11 of the 12 errors I've been getting. I just want to get the code to compile, I'll fix the errors in program when I'm able to compile, and there is an error in line 40 saying expected declaration before '}' token so I'm wondering where in the program do I need to fix this?

    Code:
    #include <iostream>
    #include <stdlib.h>
    
    
    using namespace std;
    
    void menu (void);
    
    int main()
    {
    
    
    float number,result;
    
    float numero = 5000.00;
    
    void menu (void);
    
    void check_balance(void);
    
    char choice;
    
    menu();
    cin >> choice;
    
    while(choice !='d' && choice != 'D' && choice != 'w' && choice != 'W' && choice != 'b' && choice != 'B' && choice != 'Q' && choice != 'q')
    {
    cout << "It's not a valid entry." << endl;
    menu();
    cin >> choice;
    
    }
    
    if (choice == 'd' || choice == 'D')
    {
    cout << "How much will you deposit?" << endl;
    cin >> number;
    }
    result = (number + numero);
    }}
    
    if (choice == 'w' || choice == 'W')
    {
    cout << "How much will you withdraw?" << endl;
    cin >> number;
    result = (numero - number);
    }
    }
    if (choice == 'b' || choice == 'B')
    {          
               
    void print_balance (void);
    
    cout << "Your balance is " << balance  << " dollars." << endl;
    }
    
    {
    else if (choice == 'q' || choice == 'Q')
    {
    return 0;
    }
    
    {
    cout << "Thank you for your transaction! Your current balance is now " << result  << " dollars." << endl;
    cout << "What would you like to do now?" << endl;
    
    return 0;
    }
    
    void menu(void);
    
    {    
    cout << "Enter D or d for deposit." << endl;
    cout << "Enter W or w for withdrawal." << endl;
    cout << "Enter B or b for balance." << endl;
    cout << "Enter Q or q to quit." << endl;
    
    } 
    
    
    void print_balance(float);
    {
    
    if (balance == balance)
    {
                
     return 0; 
    }
    else 
    {
         
    return 1;
    
    }

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,163
    1) Indent your code sensibly.

    2) Look at line 40. It has two closing braces. The first matches the opening brace at the start of main(). The second does not match anything, hence the error. Remove it.

    3) After doing that, your compiler will still report errors, reflecting subsequent problems in your code.
    Right 98% of the time, and don't care about the other 3%.

  3. #3
    zfk
    zfk is offline
    Registered User
    Join Date
    Dec 2010
    Location
    China
    Posts
    7
    Code:
    void print_balance(float);
    {
    
    if (balance == balance)
    {
                
     return 0; 
    }
    else 
    {
         
    return 1;
    
    }
    the type of function is void ,but return the 'integer' type. and the end of funtion name don't have ";" . there are so many ........ in your code .

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  4. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21