いくつかの質問をして結果を表示する投票を作成しています。1 つは、働いていて結婚している女子学生の割合を計算することです。パーセントの結果が 0.00 になり続けますが、その理由がわかりません。以下は、プロジェクトの上記の部分の私のコードです
char pollAnswer[0];
char Gender[0];
int i = 0;
float female = 0;
int enteredAge;
float age = 0;
char work[0];
char married[0];
float workMarried=0;
float percentFemale;
int numChildren;
float childrenAge;
int socialMedia;
int twitter = 0;
int facebook = 0;
int google = 0;
int linkedln = 0;
do {
printf("1) Gender? (F/M)\n");
scanf("%s", &Gender[i]);
if (Gender[i] == 'F') {
female++;
}
printf("2) How old are you?\n");
scanf("%d", &enteredAge);
if (enteredAge <= 25) {
age ++;
}
printf("3) Do you work? (Y/N)\n");
scanf("%s", &work[i]);
printf("4) Are you married? (Y/N)\n");
scanf("%s", &married[i]);
if (work[i] == 'Y' && married[i] == 'Y') {
workMarried++;
}
//Need help with children part.
//printf("5) how many children do you have?");
//scanf("%d", &numChildren);
printf("6) What is the social media you use the most?\n 1. Twitter\n 2. Facebook\n 3. Google+\n 4. Linkedln\n Social Media (1-4): ");
scanf("%d", &socialMedia);
if (enteredAge <= 25) {
if (socialMedia == 1){
twitter++;
}
else if (socialMedia == 2){
facebook++;
}
else if (socialMedia == 3){
google++;
}
else linkedln++;
}
printf("Do you want to answer the poll? (Y/N)\n");
scanf("%s", &pollAnswer[i]);
} while (pollAnswer[i] == 'Y');
percentFemale = (workMarried / female);
printf("What percent of female students work and are married? %f\n", percentFemale);
//Code for average age of the children.
printf("What is the favorite social media of the students with an age less than or equal to 25 years?\n");
if (twitter > facebook && twitter > google && twitter > linkedln) {
printf("Twitter\n");
}
else if (facebook > twitter && facebook > google && facebook > linkedln) {
printf("Facebook\n");
}
else if (google > twitter && google > facebook && google > linkedln) {
printf("Google+\n");
}
else if (linkedln > twitter && linkedln > google && linkedln > facebook) {
printf("Linkedln\n");
}
return 0;
}