For age >= 25 and a Unmarried Female the Output is not correct.
A company insures its drivers if either of the following conditions
Driver is married.
Driver is an unmarried, male and above 30 years of age.
Driver is unmarried, female and above 25 years of age.Write a program to decide if a driver is to be insured using logical operators.
char ms, gender;
printf("\n\tMARRIED [Y/N]: ");
printf("\n\tGENDER [M/F]: ");
if(ms == 'Y'|| ms == 'y')//married
if(gender == 'M' || gender == 'm')//male
if(age >= 30)
printf("\n\t3. NOT INSURED\n");
if(age >= 25)
printf("\n\t5. NOT INSURED\n");
MARRIED [Y/N]: n
GENDER [M/F]: f
5. NOT INSURED
gender are single characters and not character arrays storing a string.
You are reading into
%s format specifier.
%c format specifier instead which the one for reading into a
The space before the
%c is to ignore the white spaces that may remain in the input buffer which would other have been read into
ms instead of the real input.