Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
CPP All : Operators
Concept Notes and Resources

This video explains the types of c++ operators based on number operands and purpose.

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 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 ;
}
Show the output of the following program. Assume that required header files are present. ...
Assignment, equality comparison problem #2314 

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 ;
}
Find the output of the program given below. Assume all relevant header files are included ...
Output of a ternary operator operation #2321 

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;
}
Write output of the following program using the ternary operation logic.
#include &l ...		
Ternary operator within cout chain for selective printing #2791 

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.

Initialise a character variable. Now using the ternary operator within the cout chain of  ...
Output Writing – Logical Operators #3215 

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 ;
}
Write the output of the following program and explain.
int main( )
{
int a=1,b=0;
 ...		
Finding Valid Multiple value assignments #5573 

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

(i)  x=1,024;

(ii) x=(1,024);

 

Which of the following statements is/are valid and why. int x; (i)  x=1,024; (ii) ...


Practice Problem

Some good examples to practice short answer questions on operators in c++ ...

Quizzes

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