1
#include<stdio.h>
int main()
{
    int age;
    char ms,sex;
    printf("Enter the age of the driver:");
    scanf("%d\n", &age);
    
    printf("Enter marital status of the driver:");
    scanf("%c\n", &ms);

    printf("Enter the sex of the driver:");
    scanf("%c\n", &sex);

    if ((ms =='M')||(ms == 'U' && sex == 'm' && age > 30)||(ms == 'U' && sex=='f' && age > 25))
    {
        printf("Driver should be insured\n");
    }
    else{
        printf("Driver should not be insured\n");
    }
    /* code */
    return 0;
}

At the time I am running this code, it is skipping the char input. Why is that?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278

0 Answers0