-2

I'm teaching myself C++ and was writing some code to calculate grade averages with arrays. Everything works except for when I try to display the results. I get the error "expected primary-expression before '<' token" on this line of code.

    if(grade1 >= 0 && < 60)

followed by a single cout statement and a semi-colon. I looked in the book I am using and on c++ forums. My book looks just like my example and online everyone was missing a semi-colon or something else. Is that my case too?

Thanks!

Ben Kallas
  • 13
  • 1
  • 4

3 Answers3

1

You need to include 'grade1' on both comparisons.

if (grade1 >= 0 && grade1 < 60)
S. Vaughn
  • 86
  • 1
  • 7
1

What you want is this:

if(grade1 >= 0 && grade1 < 60)

You need to provide a variable for each condition in your if statement. The grade1 variable will not carry over for other comparisons.

Tony
  • 2,890
  • 1
  • 24
  • 35
1

You must write like this

if (grade1 >= 60 && grade1 < 60){ //code here   } 
Kattie.S
  • 117
  • 1
  • 11