这是我的代码。问题是-编写代码以根据学生的出勤率检查学生有资格参加考试的天气。如果学生的出勤率超过75,则他有资格参加考试,否则,将询问他/她有健康状况。如果是,将被允许,否则将不被允许。请帮帮我。在if语句期间,我无法提供输入。
int main()
{
char response;
int clshld,per;
int clsatnd;
clshld = 330; //total no of class held
printf("no of class attended\n");
scanf ("%d", &clsatnd);
per=(clsatnd*100)/clshld; //percentage formula
printf ("\nattendence percentage is %d", per);
if (per<75)
{
printf ("\ndo you have a medical condition??");
scanf ("%c", &response);
if (response =='y')
{
printf ("\nyou can sit in the exam");
}
else
{
printf ("\nattendence too low ! you can't sit in the exam.'");
}
}
else
{
printf ("\nyou are eligible to sit in the exam.");
}
return 0;
}
尝试一下:
#include<stdio.h>
int main()
{
char response;
int clshld,per;
int clsatnd, trash;
clshld = 330; //total no of class held
printf("no of class attended\n");
scanf ("%d", &clsatnd);
scanf("%c", &trash);
per=(clsatnd*100)/clshld; //percentage formula
printf ("\nattendence percentage is %d", per);
if (per<75)
{
printf ("\ndo you have a medical condition?? ");
scanf ("%c", &response);
if (response =='y')
{
printf ("\nyou can sit in the exam");
}
else
{
printf ("\nattendence too low ! you can't sit in the exam.'");
}
}
else
{
printf ("\nyou are eligible to sit in the exam.");
}
return 0;
}