I don't know why this type of come in my program expected initializer before 'if' #include &lt;iostream&gt;
#include &lt;stdlib.h&gt;

using namespace std;

void  menu(){
    cout&lt;&lt;"1 : First Grade"&lt;&lt;endl;
    cout&lt;&lt;"2 : Second Grade"&lt;&lt;endl;
    cout&lt;&lt;"3 : Third Grade"&lt;&lt;endl;
    cout&lt;&lt;"4 : Fourth Grade"&lt;&lt;endl;
    cout&lt;&lt;"5 : Fifth Grade"&lt;&lt;endl;
    cout&lt;&lt;endl;



}
int main

    if (k=1){
        mindigit=10;
        maxdigit=99;
    }
    else if(k=2){
        mindigit=100;
        maxdigit=999;
    }
    else if(k=3){
        mindigit=1000;
        maxdigit=9999;
    }   
    else if(k=4){
        mindigit=10000;
        maxdigit=99999;
    }   
    else if(k=5){
        mindigit=100000;
        maxdigit=999999;
    }
}
char randomOperator()
    return "+-"[rand() % 2];

int main(){



    menu();
int i,question,maxdigit,mindigit;
cout&lt;&lt;"Please select grade, user numbers 1 to 5:  ";
cin&gt;&gt;i;
    if (i=1){
        mindigit=10;
        maxdigit=99;
    }
    else if(i=2){
        mindigit=100;
        maxdigit=999;
    }
    else if(i=3){ 
        mindigit=1000;
        maxdigit=9999;
    }   
    else if(i=4){
        mindigit=10000;
        maxdigit=99999;
    }   
    else if(i=5){
        mindigit=100000;
        maxdigit=999999;
    }
        cout&lt;&lt;"Enter number of questions you want to generate:  ";
        cin&gt;&gt;question;
    cout&lt;&lt;endl;
    for (int j = 1 ; j &lt;= i ; j++)
    {
        int firstNum  = rand() % (max - min + 1) + min;
        int secNum  = rand() % (max - min + 1) + min;
        char opr = randomOperator();

    }
        if(opr == '+'){
            cout&lt;&lt;"("&lt;&lt;firstNum&lt;&lt;opr&lt;&lt;secNum&lt;&lt;") = ________ \t";
            if(i= 5){
                cout&lt;&lt;"\t";
            }  
        }else if(opr == '-'){
            if(firstNum &gt; secNum){
                cout&lt;&lt;"("&lt;&lt;firstNum&lt;&lt;opr&lt;&lt;secNum&lt;&lt;") = ________ \t";
                if( i= 5){
                cout&lt;&lt;"\t";
            }    
            }else{
                cout&lt;&lt;"("&lt;&lt;secNum&lt;&lt;opr&lt;&lt;firstNum&lt;&lt;") = ________ \t";  
            if( i= 5){
                cout&lt;&lt;"\t";
            }  
            }
        }

    }
Your if statements are also incorrect, in your code you're assigning values if(i=1){ rather than testing for them if(i==1){ see Arduino If reference