lundi 27 avril 2015

If Else Statement

My codes allows the user to enter in a score from 1-100, which will either tell them that the score is "Good", "OK", "Moron", or "Invalid".

But, when I compile these codes. The output has invalid in it too with the correct statement if it is more than 54.

For example, - if I enter in 55 it will say OK AND Invalid. - if I enter in 54 it will just say Moron.

Here are my codes:

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>

void main()

{

    int score;
    printf("Enter a Score");
    scanf("%d", &score);
    if (score >=80 && score <= 100){
        printf("Good\n",);
    }
     if (score >=55 && score <=79){
        printf("OK\n",);
    }
     if (score >=1 && score <=54){
        printf("Moron\n",);
    }
    else{
        printf("Invalid\n");
    }

    system("pause");
}

Aucun commentaire:

Enregistrer un commentaire