## Operators for comparison

Using operators for equality, inequality, greater, lesser, greater or equal, lesser or equal types of comparisons.

## Learning Objectives

- Use of comparison operators like equal to, not equal to, greater than, less than, greater than equal to, less than equal to.

## Source Code

## Run Output

## Code Understanding

** int a=10;**

Here we declare integer variable a and assigning it to value 10.

**if(a==10) cout<<a<<endl;**

Since a is equal to 10 this line will produce print result. Notice the use of == (double equal to) sign. This is different from assignment sign which is a single = (equal to) sign.

**if(a!=0) cout<<a<<endl;**

Since a is a non zero value so a!=0 will produce true result and hence this line will also produce output.

**if(a>0) cout<<a<<endl;
**Since a is 10, which is greater than 0 so this line will also produce output.

**if(a<100) cout<<a<<endl;**

Since a is 10, which is less than 100 so this line will also produce output.

**if(a >=10) cout<<a<<endl;**

Since a is 10, which is less than or equal to 10 so this line will also produce output.

**if(a <=10) cout<<a<<endl;**

Since a is 10, which is greater than or equal to 10 so this line will also produce output.

**Suggested Filename(s): **operators-comp.cpp, comparisons.cpp

CSKC| Created: 15-Dec-2017 | Updated: 28-Aug-2018|