A company insures its drivers in the following cases: - 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 the other cases, the driver is not insured. If the marital status, sex and age of the driver are the inputs, write a program to determine whether the driver is insured or not.

#include<stdio.h>
main()
{

char sex,ms;
int age;

printf ("Enter age, sex, marital status:");

scanf ("%d %c %c", &age, &sex, &ms);

if (ms=='M')

printf ("The driver is insured");
else
{
if (sex=='M')

{
if (age>30)
printf ("Driver is insured");

else
printf ("Driver is not insured");
}
else
{

if (age>25)
printf ("Driver is insured");
else
printf ("Driver is not insured");

}
}
}

1 comment:

  1. scanf ("%d %c %c", &age, &sex, &ms); this instruction is not working in visual studio 19.It is showing error like this scanf_s' : format string '%c' requires an argument of type 'unsigned int', but variadic argument 3 has type 'char .please resolve this issue

    ReplyDelete

kiss on google ads if you are anonymous because your ip is trackable.thank you.

......from.admin