Set a variable without using Arithmetic, Relational or Conditional Operator

We are given three variables, a, b, and c, and our task is to set the value of x without using any arithmetic, relational and conditional operators. We need to follow the below rules.

Method to Follow

Example

Arithmetic Operators C++ Code

Output:

JTP1 + JTP2= 13
JTP1 - JTP2 = 7
JTP1 * JTP2 = 30
JTP1 / JTP2 = 3
JTP1 % JTP2 = 1

Relational Operators

S.noRelational operatorDescription of operatorsExample snippet
1==Equal To operatorx == y
2!=Not Equal To the operatorx != y
3<Less Than operatorx < y
4<=Less Than or Equal To the operatorx <= y
5>Greater Than operatorx > y
6>=Greater Than or Equal To the operatorx >= y

Conditional Operators

Output:

The largest number between 5 and 10 is 10

Set a Variable without using Arithmetic, Relational or Conditional Operator

C++ code

Output:

45

C++ code

Output:

7





Latest Courses