So I have made this and if I switch int instead of char for a
and make %d my scan as well as use 1 or 2 for case instead of y or n it will make it through the whole program however I have tried to switch my case from 1 and 2 to y and n and it messes up half way. Been on it for a while and maybe I am missing something fresh eyes may help thanks!
Code:
#include<stdio.h>
int main(void)
{
char a;
int n;
int y;
printf("input answers with y=yes and n=no: Thanks!");
printf("\nAre you between the age of 18 and 26:");
scanf("%c", &a);
switch (a){
case 'n':
puts("do not need to register");
return 0;
case 'y':
puts("continue");
break;
default:
printf("Unclear of input");
break;
}
printf("Are you currently on active duty service:");
scanf("%d", &a);
switch (a){
case 'y':
puts("do not need to register");
return 0;;
case 'n':
puts("continue");
break;
default:
printf("Unclear of input");
}
printf("Are you a midshipmen at service academies or the coast guard:");
scanf("%d", &a);
switch (a){
case 'y':
puts("do not need to register");
return 0;
case 'n':
puts("continue");
break;
default:
printf("Unclear of input");
}
printf("Are you a student in the Officer Procurment program:");
scanf("%d", &a);
switch (a){
case 'y':
puts("do not need to register");
return 0;
case 'n':
puts("continue");
break;
default:
printf("Unclear of input");
break;
}
printf("Are you a Lawful non-immigrant on current non-immigrant visa:");
scanf("%d", &a);
switch (a){
case 'y':
puts("do not need to register");
return 0;
case 'n':
puts("continue");
break;
default:
printf("Unclear of input");
break;
}
printf("Are you a seasonal agricultural worker (H-2A vis):");
scanf("%d", &a);
switch (a){
case 'y':
puts("do not need to register");
return 0;
case 'n':
puts("continue");
break;
default:
printf("Unclear of input");
break;
}
printf("Are you confined by way of incarceration, hospitilization, and an institution for medical reasons:");
scanf("%d", &a);
switch (a){
case 'y':
puts("do not need to register");
return 0;
case 'n':
puts("continue");
break;
default:
printf("Unclear of input");
break;
}
printf("Are you handicap and continually confined to a hospital or insitution:");
scanf("%d", &a);
switch (a){
case 'y':
puts("do not need to register");
return 0;
case 'n':
puts("continue");
break;
default:
printf("Unclear of input");
break;
}
printf("Are you an individual who are born female and have changed gender to male:");
scanf("%d", &a);
switch (a){
case 'y':
puts("do not need to register");
return 0;
case 'n':
puts("If you have made it through this questionair, you then have to complete the appropiate form and send it in to Selective Services.");
break;
default:
printf("Unclear of input");
break;
}
return 0;
}