‹ back to Programming C++

NotesProgramming C++ · 3 December 2015

Logical Expressions.

Normally logical values out puts results in from of a Boolean, which can be 1 or zero . Depending on the output we can take decision for further calculations. They are great help for programming , as decisions  to be taken by computer depend on them

Symbols

Symbol Meaning Provide if answer will be true or false if 1=3 and b =5
= Assignment
> Greater a>b
!= Is not equal to A!=b
< Less than a<b
&& Logical and (a<b)&&(a==b)
|| Logical or (a<b)||(a==b)
! negation !( (a<b)||(a==b))
<= Less than or equal to
>= Greater than or equal to

Write a program that provides True (1) or False (0) if A is the largest.

Observation :

  • · We need output in 0 1, so we may use bool variable
  • · We need to compare three functions
  • (A>B)&&(A>C)

Now writing Program

#include<iostream>

using namespace std;

main()

{

int a,b,c;

bool check=0;

cout<<“Enter the value for A and B and C “<<endl;

cin>>a>>b>>c;

check=(a>>b)&&(a>>c);

cout<<“Is A the largest Number “<<check<<endl;

}

First published on fatsup.wordpress.com ↗