dimanche 8 octobre 2017

printf won't PRINT in if statement, specifically the gender variable

Below I have a code that asks for the users gender to enter a website, issue is I placed a printf function to display a message of the user's gender inside of an if statment and now it does not print.

#include #include

int main()
{
    int age;
    char gender;

    printf("How old are you? \n");
    scanf_s(" %d", &age);

    printf("What is your gender \n");
    scanf_s(" %c", &gender);

    if (age >= 18) {
        printf("You may enter this website ");
    }

        if (gender == 'f') {
            printf("m'lady");
        }

        if (gender == 'm') {
            printf("dude");
        }

    if (age < 18){
        printf("Nothing to see here!");
    }

    system("pause");
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire