Logic operators in c++
The basic logic operators are :-"and,or,not" operators.
&& - and operator
|| - or operator
! - not operator
Program 1:- To find greatest among three numbers
#include<iostream>
using namespace std;
int main ()
{
int a,b,c;
cout<<"enter any three numbers a,b,c"<<endl;
cin>>a>>b>>c;
if(a>=b&&a>=c)
{cout<<"a is greatest number"; }
if(b>=a&&b>=c)
{cout<<"b is greatest number"; }
if(c<<a&&c>=b)
{cout<<"c is greatest number"; }
return 0;
}
Program 2:-
The candidate is selected if his age is >= 18 years and height is >=172cm respectively.
No comments:
Post a Comment