Home > Software engineering >  I'm getting "Expected Error" on else if function
I'm getting "Expected Error" on else if function

Time:02-01

your text`Working on a for loop program, and I'm getting this errors.

mvb8835_hw4_q2.cpp:35:9: error: expected expression else if(piece < 5){ ^

Below is my code! Any advice/suggestions would be most appreciated!

Thank you!

if(integer >= 100){
        piece = (integer / 100);

        if(piece >= 5){
            roman  = 'D';
        }
            for(i = 0; i < piece - 5; i  ){
                roman  = 'C';
            }
        else if(piece < 5){
            
            for(i = 0; i < piece; i  ){
                roman  = 'C';
            }
        }
    integer %= 100;
    }

CodePudding user response:

Looks like you're not closing the if clause properly. Did you mean to do something like this?

if(piece >= 5){
    roman  = 'D';
    for(i = 0; i < piece - 5; i  ){
        roman  = 'C';
    }
}
else if(piece < 5){
    for(i = 0; i < piece; i  ){
        roman  = 'C';
    }
}
  • Related