lundi 2 juillet 2018

C and if's else

SO i am creating this to ask questions and terminate on a yes or no and continue on the opposite should I use if? or while?

I've tried this so far with it i just get a repeating question

# include <stdio.h>
# include <stdlib.h>
int main()
{
    char answer;
    printf("\nAre you between the age of 18 and 26: \n", answer);
    scanf("%c", &answer);
    {
        while (answer == 'n')
            printf("you do not need to register");

        while (answer == 'y')
            printf("\nAre you active duty military?: \n");
        scanf("%c", &answer);
    }
    {      
        while (answer == 'y')
            printf("\n you do not need to register");

        while (answer == 'n')
            printf("\n are you a midshipman at service academies or coast guard"); 

    }    
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire