mardi 27 septembre 2016

If else statement doesn't work in C

#include<stdio.h>

void main()
{
    //Declaration
    char grade[1];

    //Data Input
    enter code here
    printf("Enter a grade{A,B,C,D,F]: ");
    scanf("%c",&grade);

    //If Statement

    if(grade=='a'=='A')
        printf("The score for the grade 'A' is 4.00");
    else
        if(grade=='b '=='B')
            printf("The score for the grade 'B' is 3.00");
        else
            if(grade=='c'=='C')
                printf("The score for the grade 'C' is 2.00");
            else
                if(grade=='d'=='D')
                    printf("The score for the grade 'D' is 1.00");

I try it so many times but the if else statement just didn't pop up

Enter a grade{A,B,C,D,F]: a

Process returned 1 (0x1) execution time : 2.599 s Press any key to continue.

gives me this

Aucun commentaire:

Enregistrer un commentaire