Thread: whats wrong with this program?

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    1

    whats wrong with this program?

    hey i cant find out whats wrong. it just closes when you chose the #. try it

    plz help


    #include <iostream.h>
    #include <conio.h>



    int restart (char input, int x, int y);
    int start (char intput, int x, int y);
    void help (void);

    int main() {
    int input;
    cout<<"Welcome to my program!" << endl;
    cout<<"This is a program for calculating area of a rectangle or square."<< endl;
    cout<<"Please chose 1 of the following."<< endl;
    cout<<"1. START "<< endl;
    cout<<"2. Exit "<< endl;
    cout<<"3. Help"<< endl;
    cin>>input;
    switch (input) {

    case 1: int start ();
    break;
    case 2: return 0;
    break;
    case 3: void help ();
    break;
    default: cout<<"invalid entry, please try again";
    int restart ();
    break;
    }
    return 0;}


    void help (void) {
    cout<<"This program was made by Robert Girard." << endl << "any questions or problems email me at [email protected]" << endl;
    int Restart (char input, int x, int y);
    }

    int restart () {
    char input;
    cout<<"Welcome to my program!" << endl;
    cout<<"This is a program for calculating area of a rectangle or square."<< endl;
    cout<<"Please chose 1 of the following."<< endl;
    cout<<"1. START "<< endl;
    cout<<"2. Exit "<< endl;
    cout<<"3. Help"<< endl;
    cin>>input;
    switch (input) {


    case 1: int start ();
    break;
    case 2: return 0;
    break;
    case 3: void help ();
    break;
    default: cout<<"invalid entry, please try again";
    int restart ();
    break;
    }
    }

    int start () {
    int x;
    int y;
    char restart2;
    cout<< "please enter a length"<<endl;
    cin>>x;
    cout<< "please enter a width"<<endl;
    cin>>y;
    return x*y;
    cout<< "restart (y/e)"<<endl;
    cin>>restart2;
    if (restart2 == y)
    {
    restart ();
    }else if (restart2 == y){
    return 0;
    }else
    {
    cout<< "invalid entry, shuting down";
    return 0;
    }
    }

  2. #2
    Unregistered
    Guest
    use exit() instead of return 0; for case 2

    my preference is to use loops rather than recursion for this type of problem.

    drop the keyword int in the following lines in main():

    case 1: int start ();
    int restart ();


    Restart is different than restart to the compiler.

    each call to restart needs a char and two ints according to the prototype you wrote, but none of the function calls have any arguments and the first line of the function definition doesn't equal the prototype.

    Learn how to use a debugger. All of these problems (and maybe more) should have been picked up at compile time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Maze Program - What am I doing wrong?
    By Gipionocheiyort in forum C++ Programming
    Replies: 20
    Last Post: 08-02-2007, 01:31 PM
  2. Replies: 5
    Last Post: 01-13-2007, 02:14 AM
  3. What is wrong with my code? My first program......
    By coreyt1111 in forum C++ Programming
    Replies: 11
    Last Post: 11-14-2006, 02:03 PM
  4. Whats wrong with this program - Output of a series
    By duffmckagan in forum C Programming
    Replies: 2
    Last Post: 07-26-2006, 09:57 AM
  5. Whats wrong with my program?
    By Ruflano in forum C++ Programming
    Replies: 5
    Last Post: 02-21-2002, 05:09 PM