Problem with code?

Hello, I tried to make a program that would ask for 3 values (or scores), and then make an average of them,but it wont work and I can't seem to find what is wrong with my code.

Here it is.




//Exercise 3 Chapter 1
//First Try

#include <iostream>
using namespace std;
int main()

{
int scoreOne, scoreTwo, scoreThree
cout << "Hello, welcome to score average maker\n" <<endl;
cout << "Please enter your first score: \n" <<endl;
cin << scoreOne

cout << "Please enter your second score: \n" <<endl;
cin << scoreTwo

cout <<"Please enter your third and last score: \n" <<endl;
cin << scoreThree


int finalScore
cout <<"Final averaged score is: " << ( scoreOne + scoreTwo + scoreThree ) / 3 <<endl;
return 0;

}
cin is an instantiation of the istream class and the appropriate operator for using it is >> not <<.

Also, all of the cin commands there plus the declaration of finalScore are missing a terminator at the end of the line.

http://www.cplusplus.com/reference/iostream/istream/
Last edited on
What do you mean by terminator?
;
Fixed the code! Keep in mind I started coding yesterday night!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//Exercise 3 Chapter 1
//First Try

#include <iostream>
using namespace std;
int main()

{
    short int scoreOne, scoreTwo, scoreThree;
    cout << "Hello, welcome to score average maker\n";
    cout << "Please enter your first score: ";
    cin >> scoreOne;
    
    cout << "Please enter your second score: ";
    cin >> scoreTwo;
    
    cout <<"Please enter your third and last score: ";
    cin >> scoreThree;
    
     
    int finalScore;
    cout <<"Final averaged score is: " << ( scoreOne + scoreTwo + scoreThree ) / 3 <<endl;
    cout <<"Press enter key to exit.";
    cin.ignore();
    cin.get();
    
    return 0;     
    
}
Topic archived. No new replies allowed.