0

The goal here is to do the following: A person is doing a job application, and the only scenario where she is accepted, is if she is Female, and Under or Equal to 25 years old.

Now, this is my first time writing a code using char variables, but I'm not really sure what I have done wrong. The program manages to compile, but if you type in your age as "24", and your gender as "F"(female), it was supposed to return "Congratulations! You're hired!". Instead, it does the opposite. Anyway, hope somebody can help me here.

    int main()
{
    int age;
    char gender;

    printf("Insert your age:\n");
    scanf("%d", &age);

    printf("Insert your gender (M or F):\n");
    scanf("%c", &gender);

    if ((gender == 'F') && (age <= 25))
    {
        printf("Congratulations, you're hired!\n");     
    }
    else
    {
        printf("Sorry, you were not accepted.\n");
    }
}
Tiramonium
  • 557
  • 5
  • 15

0 Answers0