Previous | Home | Next |
In this program sex and ms are the variable of char type and age is the variable of integer type. and operator is denoted as && and or operator is denoted as ||
#include <stdio.h> #include <conio.h> main() { char sex, ms; int age; clrscr(); printf ("Enter Age, Sex, Merital Status"); scanf ("%d %c %c" &age,&sex,&ms); if ((ms=='M')||(ms=='U'&&sex=='M'&&age>30)||(ms=='M')|| (ms=='M'&&sex=='F'&&age>25)) printf ("Driver is insured"); else printf ("Driver is not insured"); }
Enter Age, Sex, Marital Status
35 F M
Driver is insured
Previous | Home | Next |