A company insures its drivers in the following cases:
- If the driver is married.
- If the driver is unmarried, male and above 30 years of age.
- If the driver is unmarried, female and above 25 years of age.
In all the other cases, the driver is not insured.
If the marital status, sex and age of the driver are the inputs,
write a program to determine whether the driver is insured or not.
- If the driver is married.
- If the driver is unmarried, male and above 30 years of age.
- If the driver is unmarried, female and above 25 years of age.
In all the other cases, the driver is not insured.
If the marital status, sex and age of the driver are the inputs,
write a program to determine whether the driver is insured or not.
#include
main()
{
char sex,ms;
int age;
printf ("Enter age, sex, marital status:");
scanf ("%d %c %c", &age, &sex, &ms);
if (ms=='M')
printf ("The driver is insured");
else
{
if (sex=='M')
{
if (age>30)
printf ("Driver is insured");
else
printf ("Driver is not insured");
}
else
{
if (age>25)
printf ("Driver is insured");
else
printf ("Driver is not insured");
}
}
}
the result is not displaying the marital status of the driver
ReplyDelete//can anyone tell me whats the error in my programme, i unable to enter sex//
ReplyDeletechar sex,ms;
int age;
printf ("Enter age");
scanf("%d", &age);
printf("Enter Sex");
scanf("%c", &sex);
printf("\nEnter MS");
scanf("%c", &ms);
if (ms=='M')
printf ("The driver is insured");
else
{
if (sex=='M')
{
if (age>30)
printf ("Driver is insured");
else
printf ("Driver is not insured");
}
else
{
if (age>25)
printf ("Driver is insured");
else
printf ("Driver is not insured");
getch();
}
}
}
check the the letter should be in capital
Deletechar is only one varible,key press one time but prog 2time read so this candition use getcher
DeleteHello friend u hv to write getch(); before last closing braces .... now its work finely ...
ReplyDeletei am unable to enter third input can anyone help?
ReplyDelete#include
ReplyDelete#include
void main()
{
char gender,ms;
int age;
clrscr();
printf ("Enter age, gender, marital status:");
scanf ("%d %c %c", &age, &gender, &ms);
if (ms=='M')
{
printf ("The employee is insured");
}
else if (ms=='U' && gender=='M' && age>30)
{
printf ("employee is insured");
}
else if (ms=='U' && gender=='F' && age>25 )
{
printf ("employee is insured");
}
else
{
printf ("employee is not insured");
}
getch();
}
plz tell me whats wrong in this
Use scanf("\n%.....)
DeleteHeader file
Delete#include
#include
#include
ReplyDeleteint main()
{
char sex,marital_status;
int age;
printf("Enter age,sex and marital status\n");
scanf("%d%c%c",&age,&sex,&marital_status);
if((marital_status=='married')||(marital_status=='unmarried'&&sex=='male'&&age>30)||(marital_status=='unmarried'&&sex=='female'&&age>25))
printf("Driver should be insured \n");
else
printf("Driver should not be insured \n");
return 0;
}
please tell me why my program is not running.
Character ma single Alphabet hota hai
Delete#include
ReplyDeletevoid main()
{
char ms;
int age,gen;
printf("enterr the marrige status,gender,age(Male = 0, female = 1) = ");
scanf("%c%d%d",&ms,&gen,&age);
if(ms == 'M')
{
printf("driver should be insured\n");
}
else
{
if(gen== 0)
{
if(age>30)
{
printf("driver should be insured\n");
}
else
{
printf("driver should'nt be insured\n");
}
}
else
{
if(age>25)
{
printf("driver should be insured\n");
}
else
{
printf("driver should'nt be insured\n");
}
}
}
}
here you are facing problem because your are using integer before the char, but if you'll use char as input in starting then your problem will be solved, try it
Sex enter is not run
ReplyDeleteThis question is solved using Switch case ...
ReplyDelete