Compiling issue

Chris
2012-01-27
2012-09-26
  • Chris

    Chris - 2012-01-27

    I'm new to programming and was trying to do a simple counting program from an
    online tutorial. Copied the syntax down exactly but I get errors every time I
    attempt to compile it. Here is a log of the errors and below that is a copy of
    the script. I'm just not sure what I'm doing wrong exactly. Tried correcting
    the errors and was still getting errors messages. : /

    35 C:\Gumballs.cpp expected primary-expression before '<<' token
    39 C:\Gumballs.cpp expected while' before numeric constant 39 C:\Gumballs.cpp expected(' before numeric constant
    39 C:\Gumballs.cpp expected )' before ';' token 40 C:\Gumballs.cpp expected}' at end of input

    include<iostream>

    include<ctime>

    using namespace std;

    int main(void)
    {
    int iGumballs;
    int iUserguess;
    int iGuesses = 0;

    while(true)
    {
    system("CLS");
    cin.clear();
    iGuesses = 0;

    srand(static_cast<unsigned int="">(time(0)));
    iGumballs = rand()%1000+1;
    cout << "How many Gumballs are in the jar?"
    << endl;
    do
    {
    cout << "Enter your guess: ";
    cin >> iUserguess;
    if(iUserguess > iGumballs)
    {
    cout << "Too High!" << endl << endl;
    }
    if(iUserguess < iGumballs)
    {
    cout << "Too Low!" << endl << endl;
    }
    iGuesses ++;
    while(iUserguess > iGumballs || iUserguess < iGumballs);
    cout << "You are right" ; << endl << endl;
    cout << "You took " << iGuesses << " guesses" << endl << endl;
    system("PAUSE");
    }
    return 0;
    }

     
  • Chris

    Chris - 2012-01-29

    Nevermind. I fixed the problem.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks