Hi I am new to programming. I have written a code for a problem mentioned below
Q. A driver is insured if
conditions:
1)Driver is married
2)Driver is unmarried,male,above 30 yrs of age
3)Driver is unmarried,female,above 25 yrs of age
The problem I am facing is- after entering age I am not able to enter marital status, the output screen looks like this-
Enter age: 28
Enter marital status m/u Enter sex m/f ("when i give a character here the program ends")
Driver is not insured
Code is given below.
A.
#include<stdio.h>
int main()
{
int a;
char ms,sx;
printf("Enter age: ");
scanf("%d",&a);
printf("Enter marital status m/u ");
scanf("%c",&ms);
printf("Enter sex m/f ");
scanf("%c",&sx);
if((ms=='m')||(a>30&&ms=='u'&&sx=='m')||(a>25&&ms=='u'&&sx=='f'))
printf("Driver is insured");
else
printf("Driver is not insured");
return 0;
}