C++ help

Discussion in 'OT Technology' started by Jonathan77, May 6, 2009.

  1. Jonathan77

    Jonathan77 Dreamer, Nostalgic with the state of mind

    Joined:
    Aug 14, 2004
    Messages:
    2,437
    Likes Received:
    0
    Location:
    Atl, Ga
    I can't seem to get my programs to compile correctly without getting an error. I get two errors for this one. Unrecognized symbol and "expected"

    #include <iostream.h>


    void main()
    {
    int number;
    int quarters, dimes, pennies;

    quarters = 0;
    dimes = 0;
    pennies = 0;

    cout<<"Enter the amount: ";
    cin>>number;

    if (number > 99)
    {
    cout<<"The entered amount is too big!";
    cin.get();
    cin.get();
    return(0);
    }

    quarters = number / 25;
    number = number - (quarters * 25);
    dimes = number / 10;
    number = number - (dimes * 10);
    pennies = number;

    if (quarters == 1)
    cout<<quarters<<" quarter ,";
    else
    cout<<quarters<<" quarters, ";

    if (dimes == 1)
    cout<<dimes<<" dime, and ";
    else
    cout<<dimes<<" dimes, and ";

    if (pennies == 1)
    cout<<pennies<<" penny.";
    else
    cout<<pennies<<" pennies.";

    cin.get();
    cin.get();
    return(0);
    }


    Any help is appreciated
     
  2. Limp_Brisket

    Limp_Brisket New Member

    Joined:
    Jan 2, 2006
    Messages:
    48,422
    Likes Received:
    0
    Location:
    Utah
    line numbers would help

    also you might need to use the std namespace
     
  3. Jonathan77

    Jonathan77 Dreamer, Nostalgic with the state of mind

    Joined:
    Aug 14, 2004
    Messages:
    2,437
    Likes Received:
    0
    Location:
    Atl, Ga
    wtf it's still giving me 2 errors. "Unrecognized symbol and no main function".




    #include <iostream>

    using namespace std;

    int main()
    {
    int number;
    int quarters, dimes, pennies;

    quarters = 0;
    dimes = 0;
    pennies = 0;

    cout<<"Enter the amount: ";
    cin>>number;

    if (number > 99)
    {
    cout<<"The entered amount is too big!";
    cin.get();
    cin.get();
    return(0);
    }

    quarters = number / 25;
    number = number - (quarters * 25);
    dimes = number / 10;
    number = number - (dimes * 10);
    pennies = number;

    if (quarters == 1)
    cout<<quarters<<" quarter ,";
    else
    cout<<quarters<<" quarters, ";

    if (dimes == 1)
    cout<<dimes<<" dime, and ";
    else
    cout<<dimes<<" dimes, and ";

    if (pennies == 1)
    cout<<pennies<<" penny.";
    else
    cout<<pennies<<" pennies.";

    cin.get();
    cin.get();
    return(0);
    }
     
  4. Limp_Brisket

    Limp_Brisket New Member

    Joined:
    Jan 2, 2006
    Messages:
    48,422
    Likes Received:
    0
    Location:
    Utah
    i just straight copied and pasted that thing into visual studio and it ran. what compiler are you using.
     
  5. critter783

    critter783 OT Supporter

    Joined:
    Jul 15, 2005
    Messages:
    1,785
    Likes Received:
    0
    Same here, Visual Studio compiled it correctly.
     
  6. Jonathan77

    Jonathan77 Dreamer, Nostalgic with the state of mind

    Joined:
    Aug 14, 2004
    Messages:
    2,437
    Likes Received:
    0
    Location:
    Atl, Ga
    Indeed
     
    Last edited: May 6, 2009
  7. GOGZILLA

    GOGZILLA Double-Uranium Member

    Joined:
    Jan 16, 2003
    Messages:
    10,760
    Likes Received:
    3
    Location:
    Plantation, FL
    copy paste your compile errors if you want help on them dude, those can mean anything
     
  8. Jonathan77

    Jonathan77 Dreamer, Nostalgic with the state of mind

    Joined:
    Aug 14, 2004
    Messages:
    2,437
    Likes Received:
    0
    Location:
    Atl, Ga
    .
     
    Last edited: May 6, 2009
  9. Limp_Brisket

    Limp_Brisket New Member

    Joined:
    Jan 2, 2006
    Messages:
    48,422
    Likes Received:
    0
    Location:
    Utah
    you might not have to include that line for that shitty compiler.

    p.s. that shitty compiler gives shitty errors.
     
  10. Jonathan77

    Jonathan77 Dreamer, Nostalgic with the state of mind

    Joined:
    Aug 14, 2004
    Messages:
    2,437
    Likes Received:
    0
    Location:
    Atl, Ga
    ok did this and still getting two errors on the shitty compiler


    #include <iostream.h>

    //using namespace std;

    void main()
    {
    int number;
    int quarters, dimes, pennies;

    quarters = 0;
    dimes = 0;
    pennies = 0;

    cout<<"Enter the amount: ";
    cin>>number;

    if (number > 99)
    {
    cout<<"The entered amount is too big!";
    cin.get();
    cin.get();
    return();
    }

    quarters = number / 25;
    number = number - (quarters * 25);
    dimes = number / 10;
    number = number - (dimes * 10);
    pennies = number;

    if (quarters == 1)
    cout<<quarters<<" quarter ,";
    else
    cout<<quarters<<" quarters, ";

    if (dimes == 1)
    cout<<dimes<<" dime, and ";
    else
    cout<<dimes<<" dimes, and ";

    if (pennies == 1)
    cout<<pennies<<" penny.";
    else
    cout<<pennies<<" pennies.";

    cin.get();



    ERROR >> unrecognized symbol

    ERROR >> >> expected
     
  11. Limp_Brisket

    Limp_Brisket New Member

    Joined:
    Jan 2, 2006
    Messages:
    48,422
    Likes Received:
    0
    Location:
    Utah
    how come you use void main for that compiler and int main for the other? plus i notice in your first post you have void main yet you return 0, that could be a problem.

    for the ">> expected" it might be complaining about cin.get(). but really, any teacher that expects you to use a compiler that doesn't even give line numbers should be shot.
     
  12. critter783

    critter783 OT Supporter

    Joined:
    Jul 15, 2005
    Messages:
    1,785
    Likes Received:
    0
    This compiler doesn't seem to recognize cin at all. Commenting out all the cin lines takes care of both errors, but that doesn't really do you a whole lot of good.

    Edit: Your first use of cin, cin >> number, works in this compiler. Its the cin.get() calls that it doesn't like. It seems to expect cin to be followed by an extraction operator.
     
    Last edited: May 6, 2009
  13. Jonathan77

    Jonathan77 Dreamer, Nostalgic with the state of mind

    Joined:
    Aug 14, 2004
    Messages:
    2,437
    Likes Received:
    0
    Location:
    Atl, Ga



    Yea I just did that and found this out. Son of a....
     
  14. Jonathan77

    Jonathan77 Dreamer, Nostalgic with the state of mind

    Joined:
    Aug 14, 2004
    Messages:
    2,437
    Likes Received:
    0
    Location:
    Atl, Ga
    Found the problem and fixed. Thanks for your help guys. Gave me the clues I needed.
     
  15. critter783

    critter783 OT Supporter

    Joined:
    Jul 15, 2005
    Messages:
    1,785
    Likes Received:
    0
    So what was it?
     
  16. critter783

    critter783 OT Supporter

    Joined:
    Jul 15, 2005
    Messages:
    1,785
    Likes Received:
    0
    This thing is a monumental piece of shit. Instead of giving line numbers where errors occurred, it puts the error right after the line. I found this out when trying to include <cstdlib>, which it didn't recognize.
     
  17. Limp_Brisket

    Limp_Brisket New Member

    Joined:
    Jan 2, 2006
    Messages:
    48,422
    Likes Received:
    0
    Location:
    Utah
    :rofl::rofl:
     
  18. Jonathan77

    Jonathan77 Dreamer, Nostalgic with the state of mind

    Joined:
    Aug 14, 2004
    Messages:
    2,437
    Likes Received:
    0
    Location:
    Atl, Ga

    well this compiler doesn't have functions for loops, float type,
    cin.get() method, operator >>, can't be used with arrays and so on. Basically this comipiler is what you said below :rofl::rofl:


     

Share This Page