mercredi 22 mars 2017

An IF statement right before nested IF-ELSE

I'm new to all of this and I'm in the middle of a lab for university. I've completed it so the program does what I want it to do but my question is regarding if this is considered good program structure.

if(speed > SPEED_LIMIT)
    printf("Speeding!\n");

if(speed >= 80)
{
    printf("A fine of $%d has been issued!\n", FINE_C);
}
else
    if(speed >= 70)

Is it alright to have a Basic IF statement before then going into a nested IF-ELSE?

Might be a weird question, only the second week into learning programming and our unit is in C.

Thanks for your time.

Aucun commentaire:

Enregistrer un commentaire