Sunday 10 June 2018

Lesson 6-Logic operations, And operation, Or operation, Not Operation - coding overdose

Logic operators in c++

&& - 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.


#include <iostream>
using namespace std;
int main ()

{

    float age,height;
    cout<<"enter age and height"<<endl;
    cin>>age>>height;



      if(age>=18 && height>=172)
    {
        cout<<"congrats!! candidate selected";
    }


else    {
        cout<<"sory.. candidate not selected";
    }

    return 0;


}



























Program 3:- 













No comments:

Post a Comment