Evaluate the value of n if the value of p=5, q=19
int n=(q-p) >(p-q)? (q-p) :(p-q)
Answers
Here is your answer
The ternary operator is an operator that takes three arguments. The first argument is a comparison argument, the second is the result upon a true comparison, and the third is the result upon a false comparison. If it helps you can think of the operator as shortened way of writing an if-else statement.
Syntax
condition ? value_if_true : value_if_false
p=5, q=19
int n=(q-p) >(p-q)? (q-p) :(p-q)
q-p=19-5= 14
p-q=5-19=-14
so ur condition statement becomes
n = 14 > -14 ? 14 : -14
So value of n= 14
I Hope this helped yo so plz rate the answer
They said to find the Value of n ...
condition given (q-p)>(p-q)?
True False option are (q-p):(p-q)... respectively.
When we solve our condition we get...
19-5>5-19
14>-14
So we get to know the CONDITION given Is true.
hence we will solve the The True option i.e the first option......
q-p
19-5
14.....answer
Hope it helps!!!!