If Else Assignment
If Else Assignment
Farhan Mahtab
CSE115.3
2422232642
Question 1: if a number is positive or not.
Code:
#include <stdio.h>
int main()
int x;
scanf("%d", &x);
if (x>0)
else if (x<0)
else
printf("\n0 is an Integer\n");
return 0;
}
Result:
Question 2: BMI calculator.
Code:
#include <stdio.h>
int main()
float h, w, BMI;
scanf("%f", &h);
scanf("%f", &w);
BMI = (703*(w/(pow(h,2))));
if (BMI<=18.4)
return 0;
Result:
Question 3: Odd / Even number.
Code:
#include <stdio.h>
int main()
int x;
scanf("%d", &x);
if (x%2==0)
else if (x%2!=0)
return 0;
Result:
Question 4: Leap year
Code:
#include <stdio.h>
int main()
int year;
scanf("%d", &year);
else if (year%400==0)
else
return 0;
}
Result:
Question 5: Regular or Not.
Solve:
#include <stdio.h>
int main()
scanf("%f", &td);
scanf("%f", &pd);
if (per>=75)
else if (per<75)
return 0;
}
Result:
Question 6: Slow or not to come to class.
Code:
#include <stdio.h>
int main()
float time;
scanf("%f", &time);
else if (time>9.35)
printf("\nCan
return 0;
}
Result:
Question 7: Progotishil or Not.
Code:
#include <stdio.h>
int main()
scanf("%f", &tm);
scanf("%f", &om);
if (per>=80)
else if (per<80)
return 0;
}
Result:
Question 8: Pass or Fail in grade.
Code:
#include <stdio.h>
int main()
scanf("%f", &tm);
scanf("%f", &om);
if (per>=60)
else if (per<60)
return 0;
}
Result:
Question 9: Got A or not
Code:
#include <stdio.h>
int main()
scanf("%f", &tm);
scanf("%f", &om);
if (per>=93)
else if (per<93)
return 0;
}
Result:
Question 10: If temperature is too hot or not
Code:
#include<stdio.h>
int main()
float T;
scanf("%f", &T);
if (T>=33)
if (T<15)
}
return 0;
Result: