Hello!
I want to write a program that it writes to the screen
--if the driver is married
--if the driver is unmarried,male,above 30 years of age
--if the driver is unmarried,female,above 25 years of age.
i wrote this when i compile it gives abnormal results i can't understand
please find my faults
Code:
#include <stdio.h>
int main()
{
char ms,sex;
int age;
printf("Enter Marry or Unmarry Status\nSex\nAge\n");
scanf("%c%c%d",&ms,&sex,&age);
if(ms=='M')
printf("Insured\n");
else if(ms=='U'&&sex=='m'&&age>30)
printf("Insured\n");
else if(ms=='U'&&sex=='f'&&age>25)
printf("Insured\n");
else
printf("Uninsured\n");
main();
}
Code:
#include <stdio.h>
int main()
{
char ms,sex;
int age;
printf("Enter Marry or Unmarry Status\nSex\nAge\n");
scanf("%c%c%d",&ms,&sex,&age);
if((ms=='M')||(ms=='U'&&sex=='M'&&age>30)||(ms=='U'&&sex=='F'&&age>25))
printf("Insured\n");
else
printf("Uninsured");
main();
}
i could't work correctly my program with these two codes