Give expressions for Binary and Ternary Operator
NO SPAMS......
Answers
Answered by
21
==================================
⭐⭐⭐⭐⭐ ANSWER ⭐⭐⭐⭐⭐
==================================
❄❄ BINARY OPERATOR ❄❄
✔ An airthmetic operator which deals with two operands is known as Binary arithmetic operator.
✔ Example : +, -, *, /, %
✔ Expressions : a+b, a-b, a*b, a/b, a%b
==================================
❄❄ TERNARY OPERATOR ❄❄
✔ Ternary operator deals with three operands.
✔ Syntax : Variable = (test expression)? Expressiom 1 : Expression 2.
[The variable contains the expression 1 if the test condition is true otherwise expression 2].
✔ Example :
a = 5; b = 3;
Max = (a>b)? a : b;
Here, the value 5 is stored in Max, as a>b is true.
Min = (b>a)? a : b;
Here, value of 3 is stored in Min, as b>a is true.
==================================
✌✌✌ OUTCOMES ✌✌✌
Rewrite the snippet using Ternary Operators :
if(a>b)
{
d = (a-b);
else
d = (b-a);
}
Ans. d = (a>b)? (a-b) : (b-a) ;
==================================
⭐⭐⭐ ALWAYS BE BRAINLY ⭐⭐⭐
==================================
⭐⭐⭐⭐⭐ ANSWER ⭐⭐⭐⭐⭐
==================================
❄❄ BINARY OPERATOR ❄❄
✔ An airthmetic operator which deals with two operands is known as Binary arithmetic operator.
✔ Example : +, -, *, /, %
✔ Expressions : a+b, a-b, a*b, a/b, a%b
==================================
❄❄ TERNARY OPERATOR ❄❄
✔ Ternary operator deals with three operands.
✔ Syntax : Variable = (test expression)? Expressiom 1 : Expression 2.
[The variable contains the expression 1 if the test condition is true otherwise expression 2].
✔ Example :
a = 5; b = 3;
Max = (a>b)? a : b;
Here, the value 5 is stored in Max, as a>b is true.
Min = (b>a)? a : b;
Here, value of 3 is stored in Min, as b>a is true.
==================================
✌✌✌ OUTCOMES ✌✌✌
Rewrite the snippet using Ternary Operators :
if(a>b)
{
d = (a-b);
else
d = (b-a);
}
Ans. d = (a>b)? (a-b) : (b-a) ;
==================================
⭐⭐⭐ ALWAYS BE BRAINLY ⭐⭐⭐
==================================
Sukanyayayayayayayay:
tysm
Answered by
8
❤❤ BINARY OPERATOR ❤❤
✔ An airthmetic operator which deals with two operands is known as Binary arithmetic operator.
✔ Example : +, -, *, /, %
✔ Expressions : a+b, a-b, a*b, a/b, a%b
==================================
❤❤ TERNARY OPERATOR ❤❤
✔ Ternary operator deals with three operands.
✔ Syntax : Variable = (test expression)? Expressiom 1 : Expression 2.
[The variable contains the expression 1 if the test condition is true otherwise expression 2].
✔ Example :
a = 5; b = 3;
Max = (a>b)? a : b;
Here, the value 5 is stored in Max, as a>b is true.
Min = (b>a)? a : b;
Here, value of 3 is stored in Min, as b>a is true.
✔ An airthmetic operator which deals with two operands is known as Binary arithmetic operator.
✔ Example : +, -, *, /, %
✔ Expressions : a+b, a-b, a*b, a/b, a%b
==================================
❤❤ TERNARY OPERATOR ❤❤
✔ Ternary operator deals with three operands.
✔ Syntax : Variable = (test expression)? Expressiom 1 : Expression 2.
[The variable contains the expression 1 if the test condition is true otherwise expression 2].
✔ Example :
a = 5; b = 3;
Max = (a>b)? a : b;
Here, the value 5 is stored in Max, as a>b is true.
Min = (b>a)? a : b;
Here, value of 3 is stored in Min, as b>a is true.
Similar questions
Math,
6 months ago
Computer Science,
6 months ago
History,
1 year ago
History,
1 year ago
Math,
1 year ago