Monday, 24 July 2017

Write a Program using Logical Operators

Write a Program using Logical Operators:

What is Logical Operators ?

Operators are special sort of features, that takes one or greater arguments and produces a new value. As an example : addition (+), subtraction (-), multiplication (*) and so on, are all operators. Operators are used to perform numerous operations on variables and constants.

       A company insures its drivers in the following cases:
·        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.

In all other cases the driver is not insured. If the marital status, gender and age of the driver are the inputs, write a program to determine whether the driver is to be insured or not.

Code:


#include<stdio.h>

#include<conio.h>
void main()
{
char g,s;
int a;
printf("Enter Martial Status m For Married And u For Unmarried ");
scanf("%c",&s);
printf("\nEnter Gender m For MAle And f For Female");
scanf("\n%c",&g);
printf("\nEnter Age ");
scanf("\n%d",&a);
if(((s=='m'))||((s=='u')&&(g=='m')&&(a>30))||((s=='u')&&(g=='f')&&(a>25)))
printf("\nDriver Is Insured");
else
printf("\nDriver Is Not Insured");
getch();
clrscr();
}

Output:


Try it yourself.
If you have any problem you can tell me on comment box i will help you.
thanks.

Viral Programs

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.

0 comments:

Post a Comment