 CPP All : Operators Concept Notes and Resources #### Operators in C++ #1730

Concept Learning Code Sheets #### Operators based on operand count #1728

Binary, unary and ternary operator classification is based on number of operands.

#### Operators for assignment #1734

Here we demonstrate the simple assignment and its variations.

#### Operators for comparison #1736

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

#### Operators for logical use #1739

Testing the use of logical operators like not, and and or operators.

#### Comma as operator #1741

Comma is a sort of operator which can help form multiple instructions within same instruction.

#### Bitwise operators #1743

Bit-wise operators work after the given operands are converted to their binary equivalent value.

#### Typecasting operator #1745

Typecasting or conversion of data type is some times essentially required. This is also a kind of operator in c++

#### Typecasting while outputting #1747

Type casting is often useful for manipulating display while outputting data.

#### sizeof operator #1750

Datatype size is found by using the sizeof operator in c++

#### Simple case of precedence #1752

The order in which operators are applied on operands in an expression can be understood with this example.

#### Operator precedence with value change within expression #1784

Learning operator precedence case when value changes while evaluating the expression.

#### Age based discount using ternary operator #2318

Solving age based discount problem with ternary (three operands) operator.

#### Largest of three numbers using nested ternary operator #2943

A program to demonstrate nesting of ternary operator while finding the largest of three numbers.

#### Modulus operator for integers #3589

Getting the remainder of an integer division using the modulus operator.

#### Assignment operator chain #5511

Here we demonstrate the assignment done in a chain fashion.

#### Multiple value assignment attempts #5571

Here we demonstrate the treatment of precedence between comma, brackets and assignment operator in a multiple value assignment scenario.

Solved Problems #### Increment, Decrement Composite Operators Problem 1 #1756

Show the output of the following program. Assume that required header files a

Show the output of the following program. Assume that required header files are present.

```int main()
{
int n=10;
cout<< n << endl ;
cout<< ++n << endl ;
cout<< n++ << endl ;
cout<< n << endl ;
cout<< - n << endl ;
cout<< - - n << endl ;
cout<< -- n << endl ;
cout<< n << endl ;
cout<< n-- << endl ;
cout<< n << endl ;
cout<< - --n <<endl;
cout<< (n+=1) <<endl;
cout<< (n-=1) <<endl;
cout<< (n%=2) <<endl;
return 0 ;
}```

#### Assignment, equality comparison problem #2314

Find the output of the program given below. Assume all relevant header files

Find the output of the program given below. Assume all relevant header files are included

```int main( )
{
int a,b,c=101,d=102;
a=(c=d);
cout<<a<<endl;
b=(c==d);
cout<<b<<endl;
return 0 ;
}```

#### Output of a ternary operator operation #2321

Write output of the following program using the ternary operation logic.

Write output of the following program using the ternary operation logic.

```#include <iostream.h>
int main()
{
int a=10,b=23;
int c=a>b?a=b:b=a;
cout<<c<<endl;
return 0;
}```

#### Ternary operator within cout chain for selective printing #2791

Initialise a character variable. Now using the ternary operator within the co

Initialise a character variable. Now using the ternary operator within the cout chain of printing, print YES if initialised variable is Y and print NO if it is anything else.

#### Output Writing – Logical Operators #3215

Write the output of the following program and explain.

```int main( )

```

Write the output of the following program and explain.

```int main( )
{
int a=1,b=0;
int c=!a && b;
cout<<(c || b+a)<<endl;
cout<<(-c && a+b)<<endl;
return 0 ;
}```

#### Finding Valid Multiple value assignments #5573

Which of the following statements is/are valid and why.
int x;

(

Which of the following statements is/are valid and why.
int x;

(i)  x=1,024;

(ii) x=(1,024);

Practice Problem #### SA-Operators Set 1 #3255

Quizzes #### Logical Operators Quiz #3214

Concept Notes:1  Code Sheets:16  Solved Problems:6  Practice Problems:2  Quizzes:3
×