C++ Program won't compile

Discussion in 'General Computer Support' started by ian5142, Mar 14, 2011.

  1. ian5142

    ian5142

    Joined:
    Mar 14, 2011
    Messages:
    1
    Hi
    I am learning C++ and I tried to make a little program that will tell me what 2 numbers are between (see code) and do 4 functions with them (+, -, *, /). I can not get the program to return one of my predetermined phrases under int a or int b, back to my cout under int main. I want to have an int a and b like this. What am I missing?

    Code :
    --------------------------------------------------------------------------------------------------------------------------------------

    #include <iostream>

    using namespace std;

    int mult ( int numnber1, int number2 );

    int divi ( int number1, int number2 );

    int subt ( int number1, int number2 );

    int addi ( int number1, int number2 );

    int a ( int number1, char p1, char p2, char p3, char p4, char p5 );

    int b ( int number2, char p1, char p2, char p3, char p4, char p5 );



    int main()
    {
    char p1 [] = "equal to 100";
    char p2 [] = "greater than or equal to 50 but less than 100";
    char p3 [] = "greater than 100 but less than 1000";
    char p4 [] = "greater than or equal to 1000";
    char p5 [] = "less than 50";
    int number1, number2;

    cout<<"Please enter 2 numbers separated by a space (largest number first): ";
    cin>> number1 >> number2;
    cin.ignore();



    cout<< "The product of "<< number1 <<" and "<< number2 <<" is "<< mult ( number1, number2 ) <<"\n";

    cout<< "The quotient of "<< number1 <<" and "<< number2 <<" is "<< divi ( number1, number2 ) <<"\n";

    cout<< "The difference of "<< number1 <<" and "<< number2 <<" is "<< subt ( number1, number2 ) <<"\n";

    cout<< "The sum of "<< number1 <<" and "<< number2 <<" is "<< addi ( number1, number2 ) <<"\n";

    cout<< " "<< number1 <<" is "<< int a ( int number1, char p1, char p2, char p3, char p4, char p5 ) <<"\n";

    cout<< " "<< number2 <<" is "<< int b ( int number2, char p1, char p2, char p3, char p4, char p5 ) <<"\n";
    }
    int mult ( int number1, int number2 )
    {
    return number1 * number2;
    }

    int divi ( int number1, int number2 )
    {
    return number1 / number2;
    }

    int subt ( int number1, int number2 )
    {
    return number1 - number2;
    }

    int addi ( int number1, int number2 )
    {
    return number1 + number2;
    }

    int a ( int number1, char p1, char p2, char p3, char p4, char p5 )
    {

    if ( number1 == 100) {
    return p1;
    }
    else if ( ( number1 < 100 ) && ( number1 >= 50 )) {
    return p2;
    }
    else if ( ( number1 > 100 ) && ( number1 < 1000) ) {
    return p3;
    }
    else if ( number1 >= 1000 ) {
    return p4;
    }
    else if ( number1 < 50) {
    return p5;
    }
    }

    int b ( int number2, char p1, char p2, char p3, char p4, char p5 )
    {

    if ( number2 == 100) {
    return p1;
    }
    else if ( ( number2 < 100 ) && ( number2 >= 50 )) {
    return p2;
    }
    else if ( ( number2 > 100 ) && ( number2 < 1000) ) {
    return p3;
    }
    else if ( number2 >= 1000 ) {
    return p4;
    }
    else if ( number2 < 50) {
    return p5;
    }
    }

    ---------------------------------------------------------------------------------------------------------------------------------

    I got these warnings and errors:

    L42 - Error: expected primary-expression before 'int'
    L42 - Error: expected ' ; ' before 'int'
    L44 - Error: expected primary-expression before 'int'
    L44 - Error: expected ' ; ' before 'int'
    L21 - Warning: unused variable 'p1'
    L22 - Warning: unused variable 'p2'
    L23 - Warning: unused variable 'p3'
    L24 - Warning: unused variable 'p4'
    L25 - Warning: unused variable 'p5'

    What am I doing wrong?
    ian5142, Mar 14, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pedro69UK

    Compile error in hidden module : NT Reg Code

    Pedro69UK, Jan 12, 2004, in forum: Computer Support
    Replies:
    0
    Views:
    724
    Pedro69UK
    Jan 12, 2004
  2. Luke O'Malley

    MS Word: compile error ???

    Luke O'Malley, Jan 20, 2004, in forum: Computer Support
    Replies:
    0
    Views:
    477
    Luke O'Malley
    Jan 20, 2004
  3. Luke O'Malley

    MS Word << compile error >> solution didn't work

    Luke O'Malley, Jan 21, 2004, in forum: Computer Support
    Replies:
    13
    Views:
    603
    Tergiversative
    Jan 22, 2004
  4. Luke O'Malley

    << COMPILE ERROR NOTICE WITH WORD 97 & EXCEL 97 >>

    Luke O'Malley, Feb 27, 2004, in forum: Computer Support
    Replies:
    2
    Views:
    1,433
  5. Bill Mazlar

    Compile linux, aix4, sgi, or sun on Mac OS X?

    Bill Mazlar, Sep 11, 2004, in forum: Computer Support
    Replies:
    22
    Views:
    1,037
    anonymous
    Sep 23, 2004
Loading...

Share This Page