【发布时间】:2020-06-16 10:48:49
【问题描述】:
这是我的代码。问题是 - 编写代码以根据学生的出勤率检查学生是否有资格参加考试。如果学生的出勤率超过 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;
}
【问题讨论】: