Helping with an error i keep getting

This is a discussion on Helping with an error i keep getting within the C++ Programming forums, part of the General Programming Boards category; Hi everyone, Iam really bad at C++, and on my home work (yes i have it completed i just dont ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    3

    Helping with an error i keep getting

    Hi everyone, Iam really bad at C++, and on my home work (yes i have it completed i just dont understand an error i keep getting) its saying a statement is missing, when obviously its there, its stumping me completely, if i delete the line the error just moves to the next line ive tried diffrent ways of displaying it but for the life of me (or maybe my terrible luck programming) I am lost as to what to do.
    please be gentle its not the best but iam trying to learn...

    Code:
    #include <iostream>
    #include <iomanip>
    using namespace std;
    
    int main()
    {
       // data declarations
       int   numTests = 5;   // The number of test scores
       // TODO
       // declare 5 test score variables (one per line, type int)
       // declare 1 test score average variable (type float or double)
             int score1;
             int score2;
             int score3;
             int score4;
             int score5;
             float avg;
    
                // Inputs
       // TODO
       // Prompt uers & get five test scores (five prompts)
           cout << "Please enter test score Number one: ";
           cin >> score1;
    
           cout << "Please enter test score Number two: ";
           cin >> score2;
    
           cout << "Please enter test score Number three: ";
           cin >> score3;
    
           cout << "Please enter test score Number four: ";
           cin >> score4;
    
           cout << "Please enter test score Number five: ";
           cin >> score5;
    
            // Processing
       // TODO
       // Calculate the total value of the tests and the average
       // Use casting if necessary
           avg=score1+score2+score3+score4+score5/numTests
    
       // Output
       // TODO
       // Display results
       // Line 1: the label
       // Line 2: the manipulators setprecision, fixed, showpoint
       // Line 3: the test score average
    
    LINE I GET ERROR-->>>
            cout <<"The average score is: ";
            cout << setprecision(3);
            cout << avg;
    
       // Program termination
     cin.ignore();
     cin.get();
     return 0;
    }

  2. #2
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    There is e semicolon missing on this line
    Code:
          avg=(score1+score2+score3+score4+score5)/numTests;
    BTW you need the () to get a correct result
    Kurt

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    3

    Thank you

    Thank you, figures it would be something as simple as that, again thank you so much.. now my head can stop hurting =)

  4. #4
    Registered User
    Join Date
    Sep 2005
    Posts
    3

    argh

    Duh static_cast
    Last edited by FlyingKoopaint; 09-13-2005 at 11:44 AM. Reason: Reading is hard

  5. #5
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282
    What compiler are you using?

    On many of them you can just double click on the error message and it will take you to the line with the error. If your does that, you could have easily seen the error.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. helping a m8 fifo/pipes
    By fortune2k in forum C Programming
    Replies: 42
    Last Post: 03-05-2009, 03:22 AM
  2. Anyone interested in helping me out again??
    By xMEGANx in forum C++ Programming
    Replies: 19
    Last Post: 10-04-2007, 01:43 AM
  3. Valve helping with Doom III?
    By RoD in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 05-14-2004, 09:41 PM
  4. An Idea on helping newbies read the FAQ
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 08-23-2002, 04:42 PM
  5. interested in helping????
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 05-05-2002, 09:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21