Skip to content

Tag Archives: cpp-operator

Ternary operator also known as conditional operator uses three operands to perform operation. Syntax : op1 ? op2 : op3; Nested Ternary operator: Ternary operator… Read More
Given a program that uses an iterator, the task is to find the type of iterator used. Examples: Input : vector.begin() Output : Random_Access Iterator… Read More
The task is to Add two number using ‘-‘ operator. Examples:  Input : 2 3 Output : 5 Input : 10 20 Output : 30… Read More
Pre-increment operator: A pre-increment operator is used to increment the value of a variable before using it in a expression. In the Pre-Increment, value is… Read More
Delete is an operator that is used to destroy array and non-array(pointer) objects which are created by new expression.  Delete can be used by either… Read More
Left Shift : Denoted as : <<  Eg: N<<i (N: first operand, i: second operand) Takes two numbers, left shifts the bits of the first… Read More
Array classes are generally more efficient, light-weight and reliable than C-style arrays. The introduction of array class from C++11 has offered a better alternative for… Read More
Stringizing operator (#) This operator causes the corresponding actual argument to be enclosed in double quotation marks. The # operator, which is generally called the… Read More
How to implement ternary operator in C++ without using conditional statements.In the following condition: a ? b: c If a is true, b will be executed. Otherwise,… Read More
Comparing String using Relational operators, Using compare() Relational operators vs std::string::compare() Return Value : Relational operators return boolean value, while compare() returns unsigned integer. Parameters… Read More
Unary operator: are operators that act upon a single operand to produce a new value. Types of unary operators: unary minus(-) increment(++) decrement(- -) NOT(!)… Read More
Consider below C++ program and predict its output. printf("%d %d %d", i, ++i, i++); The above invokes undefined behaviour by referencing both ‘i’ and ‘i++’… Read More
Given three integers a, b and c where c can be either 0 or 1. Without using any arithmetic, relational and conditional operators set the… Read More
We can find size of an array using sizeof operator as shown below. // Finds size of arr[] and stores in 'size' int size =… Read More
Consider below C++ program:   CPP // C++ program to show that local parameters hide // class members #include <iostream> using namespace std; class Test {… Read More