/Hi guys ^^ can you help me ?? i keep getting these "error C2447: missing function header (old-style formal list?)" i just want to do 2 converters and somehow i end up in doingthis, pls guys help me ^^/

# include <iostream>
# include <cstdlib>
using namespace std;

int choice;


void menu();

int main()
{


    double micrograms = 0,
           kilograms = 0,
           cups = 0,
           ounce = 0,
           metricton= 0,
           ton = 0,
           uston=0,
           rupees = 0,
           dollar = 0,
           euros = 0;

    while ( choice>=0&&choice<=9)
    {
        menu();
        cin >> choice;

        switch (choice)
        {
            case 1:
                cout << "\nEnter the number of Cups: ";
                cin >> cups;
                cout << "\n" << cups << " cups is " << cups * 0.0625 << " gallons" << endl;
            break;
            case 2:
                cout << "\nEnter the number of kilos: ";
                cin >> kilograms;
                cout << "\n" << kilograms << " kg is " << kilograms *2.20462 << " pounds." << endl;
            break;

            case 3:
                cout << "\nEnter the amount of micrograms: ";
                cin >>micrograms ;
                cout << "\n" << micrograms << " micrograms is " << micrograms * 0.001 << " milligrams. " << endl;
            break;
            case 4:
                cout << "\nEnter the amount of ounce: ";
                cin >> ounce;
                cout << "\n" << ounce << " ounce is " << ounce * 28.3495<< " grams." << endl;
            break;
            case 5:
                cout << "\nEnter the amount of metric ton: ";
                cin >> metricton;
                cout << "\n" << metricton << " metric ton is " << metricton * 0.984207 << " Imperial Ton." << endl;
            break;
            case 6:
                cout << "\nEnter the amount of ton: ";
                cin >> ton;
                cout << "\n" << ton << " ton is " << ton * 32000 << " ounce." << endl;
            break;
            case 7:
                cout << "\nEnter the amount of U.S. ton: ";
                cin >> uston;
                cout << "\n" << uston << " U.S. ton is " << uston * 0.892857 << " Imperial ton." << endl;
            case 8:
                choice = 9;
            break;
            default:
                cout << "\nPlease enter a valid choice.\n " << endl;
                choice = 0;
            }system("pause");system("cls");
        }

        cout << "End of program " << endl;

    system("pause");
    return 0;
    }

void menu()
{
cout << " Conversion in Weight: \n" << endl;
cout << "1. Cups --> Gallons: " << endl;
cout << "2. Kilograms --> Pounds: " << endl;
cout << "3. Microgram --> Milligram: " << endl;
cout << "4. Ounce --> Gram: " << endl;
cout << "5. Metric Ton --> Imperial Ton: " << endl;
cout << "6. Ton --> Ounce: " << endl;
cout << "7. US Ton --> Imperial Ton: " << endl<< endl;
cout << "To quit : type 8." << endl << endl;
}



const int MAX_CURRENCY = 3;

const string currency_name[MAX_CURRENCY] = 
{   " Pakistani Rupees",
    " Euro",
    " Dollar",
};

const double exchange_rate[MAX_CURRENCY][MAX_CURRENCY] = 
{   { 1, 0.0087, 0.0095 },  
    { 115.2, 1, 1.1 },  
    { 0.091, 104.73, 1}
};


{
    int currency1 = 0, value = 0, currency2 = 0;
    double rate = 0;

    cout << "Currency Converter *Market values accurate as of 01/08/2014*\n" << endl;

    while (true) 
    {   cout << "Available Currencies:" << endl;
        cout << "---------------------" << endl;
        for (int i=0; i<MAX_CURRENCY; i++)
            cout << i+1 << ". " << currency_name[i] << endl;

        cout << "Currencies are chosen by entering their corresponding index value.\n\n";
        cout << "Please choose a currency: ";
        cin >> currency1;
        currency1--;
        cout << "You have selected " << currency_name[currency1] << endl;
        cout << "Please enter a value in " << currency_name[currency1] << endl;
        cin >> value; 
        cout << "You have chosen " << value << currency_name[currency1] << endl;
        cout << "Please choose the currency you wish to convert to: "<< endl;
        cin >> currency2;
        currency2--;
        cout << "You have chosen " << currency_name[currency2] << endl; 
        rate = value * exchange_rate[currency1][currency2];
        cout << value << " " << currency_name[currency1] 
             << " = " << rate << currency_name[currency2] << endl<< endl;
    };

}

Recommended Answers

All 4 Replies

Line 111. Is that the start of a function or what?

@ddanbe - I think it is a continuation of main, but he exits main in his while(choice) loop back on line 79. And there is no final return value at the end (line 140).

@rubberman: you're right I guess, those dreadful, wrong posted indentations!

Main ends at line 80. I think what is needed is a function header just before line 112.

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.