If statement problems

Hey, In this program every time I enter the scores is prints the else statement at the end, can someone please help me ?
thanks.

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
30
31
32
33
34
35
  #include <iostream>
#include <string>
# define scores 8
using namespace std;

int main()
{ string  n,s;
float g;


    float assignment[scores]{};
cout <<"Please enter your name:";
cin>>n;
cin>>s;
cout<<endl;

cout <<"Please enter the scores you got in the 8 assignments"<<endl;
      for(int i=0;i<8;i++)
       {
          cin>>assignment [i];
      }
        if(assignment[scores]==g)
        {

        }
        else
        {
            cout<<"The value entered is invaild for computations."<<endl;
        }



    return 0;
}
Line 11 has an error I believe the curly braces.
Edit: Cloud 9 gave me error but cpp.sh didn't, not sure if it was the compiler i'm using or not?
2nd Edit: Your float g(line 9) doesn't have a value, so it's just garbage.
Last edited on
The program is supposed to only accept numbers.
Topic archived. No new replies allowed.