I am very confused about if-else statement problem.
The problem is this : using scanf function, assign total(double) and # of absences(int) to s, a, respectively.
Then, print out score based on standards below
if total is above 70, print out A+. In this condition, if absence date is more than 5 days, print out D.
if total is below 70, print out "A0" In this condition, if absence is more than 5 days, print out F.
In coding, you can use only 3 of if-else statement.
#include <stdio.h>
int main(void)
{
double s;
int a;
scanf("%lf%d", &s, &a);
if (_________________ )
__________________
_________________
_________________
else
__________________
__________________
________________
__________________
return 0; }
How I approached the problem is this. The total divides into two section, which is divided by the score 70. And then I put another nested if condition to regulate the effect of absence date like if if However, the problem arises out of this. I can't do like if if else if because if can't be included in else statement!!!. I can't use elseif statement neither!! I want to code like
if total >70
if absence > 5
if total <70
if absence >5
but the thing is that I can use only if-else 3 statement... Is there any to shorten the code?
Aucun commentaire:
Enregistrer un commentaire