StarkWolf1993
StarkWolf1993

Reputation: 63

expected primary-expression before '<' token error

Hi I am going back through C programming exercises and in this particular program I get an expected primary-expression before '<' token at Line 8 (The While loop). Would appreciate some clarification on what I would need to fix and the reasoning behind it. Here is the code and thank you so much!

#include <stdio.h>
#include <iostream>
using namespace std;

int main(){
   int number, i=8;
   cout <<"Please enter all numbers from 8-23\n";
   cout <<"Start Now: ";
   while (i=<23){
          cin>>number;
          cout<<"Next: ";
          if (number!=i){
             cout<<"That was the wrong, Please enter: "<<i<<endl;
          }
         else 
           i++;
    }
    cout<<"Congratulations!!\n";
return 0;
}

Upvotes: 1

Views: 1282

Answers (2)

hmjd
hmjd

Reputation: 121961

while (i=<23){ should be while(i<=23){

Upvotes: 1

cnicutar
cnicutar

Reputation: 182619

while (i=<23){
        ^^

Try while (i <= 23) instead.

Upvotes: 3

Related Questions