Program Statement:
The company insures its drivers in the following case:
If the driver is married.
If the driver is unmarried , male and above 30 years of age.
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 , gender, and age of the driver are inputs from the keyboard. Write a program to determine whether the driver is to be insured or not.
source code
#include <stdio.h>
int main()
{
int age;
char ms,gen;
printf(" enter marital status , gender, and age information\n");
scanf(" %c %c%d",&ms,&gen,&age);
if(ms=='M')
printf("\n Driver is Insured");
else
if(ms=='U' && gen=='M' && age>30)
printf("\n Driver is Insured");
else
if(ms=='U' && gen=='F' && age>25)
printf("\n Driver is Insured");
else
printf("\n Driver is not Insured");
return 0;
}
output:
1)
enter marital status , gender, and age information
U
M
35
Driver is Insured
2)
enter marital status , gender, and age information
U
M
24
Driver is not Insured
3)
enter marital status , gender, and age information
U
F
28
Driver is Insured
4)
enter marital status , gender, and age information
U
F
23
Driver is not Insured
0 Comments
Post a Comment