Hi guys,
I just started out and I am having some difficulty getting my program to work. I was following an online guide to this program but it ended sorta midway and I am left quite baffled.
Code:
#include <stdio.h>
int main (void)
{
int userAge;
printf("How old are you?\n");
scanf("%d", &userAge);
char citizen[3] = {'\0'};
printf("Are you a citizen of the USA?\n");
scanf("%s", citizen);
if (userAge >= 18 && citizen == ("yes")) {
printf ("Yup ya can vote boo. Go get 'em");
}
else {
printf("You are not eligible to vote. Soz.");
}
getchar ();
getchar ();
return 0;
}
The problem is the citizen variable. I want the user to input a positive or negative answer to the question but I am pretty sure I am doing it wrong. Can anyone help out? Plus if you could I would really appreciate if you could explain to me why do I need the & character before userAge?
And of course I would greatly appreciate if you had any online course to recommend that would cater to my basic needs
Have a great day!