32. C Program To Check Status of a given Problem using Nested If Condition.
How does this program work?
- In this program you are going to learn about How to check status using nested if condition in C language.
Here is the code
//1. If the driver is married
//2. If the driver is unmarried, male and above 30 years of age
//3. If the driver is unmarried, female and above 25 years of age
//In all other cases, the driver is not insured.
//If the marital status, sex, age of the driver are the inputs,
//write a program to determine whether the driver is insured or not. (use ‘nested-if’).
#include <stdio.h>
int main(void)
{
char ge,ms;
int age;
printf ("Enter marital status(M/N):\n");
scanf (" %c", &ms);
printf ("Enter Gender(M/F):\n");
scanf (" %c", &ge);
printf ("Enter Age:\n");
scanf (" %d", &age);
if (ms=='M')
{
printf ("The driver is insured");
}
else if (ge=='M' && age>30 && ms=='N')
{
printf ("Driver is insured");
}
else if (ge=='F' && age>25 && ms=='N')
{
printf ("Driver is insured");
}
else
{
printf ("Driver is not insured");
}
return 0;
}