0

This is my code and in this the age, marital status and gender input are not working please help me fix this I am noob and new to stack overflow ;(

#include <stdio.h>
    
    int main(){
        int age;
        char ms;
        char gender;
        printf("\nEnter age: ");
        scanf("%d",&age);
        printf("\nEnter marital status: ");
        scanf("%c",&ms);
        printf("\nEnter gender: ");
        scanf("%c",&gender);
    
        if(ms=='M'||ms=='U'&&gender=='M'&& age>=30||ms=='U'&&gender=='F'&& age>=25)
        printf("Driver is insured.");
        return 0;
    }
  • 2
    Does this answer your question? [scanf() leaves the newline character in the buffer](https://stackoverflow.com/questions/5240789/scanf-leaves-the-newline-character-in-the-buffer) – Passerby Dec 07 '21 at 06:53
  • 2
    Your condition in the `if` will probably not work as you expect. – Some programmer dude Dec 07 '21 at 06:54
  • Please split your if statement conditions. Also to check if scanf is taking an input do a printf of that variable. – Vincent Dec 07 '21 at 08:08

0 Answers0