mercredi 6 septembre 2017

why isn't char accepting the long strings?

In this program the person is being insured if he/she is married or if unmarried then male is suppose to be 30 or more and female to be 25 or old.

#include <stdio.h>
#include <stdlib.h>

int main()
{
int age;
char sex, ms[20];

printf("Enter your maritial status : \n");
scanf(" %ls", ms);

printf("Enter your sex (m/f) : \n");
scanf(" %c", &sex);

printf("Enter your age : \n");
scanf(" %d", age);

if((ms == 'married') || (sex=='m' && age>=30 && ms=='unmarried')|| 
 (ms=='unmarried' && age>=25 && sex='f')){
    printf("You are insured ");
}
else{
    printf("You are not insured");
}

return 0;

getchar();
}

Aucun commentaire:

Enregistrer un commentaire