Evaluate the value of n if value of p = 5, q = 19

int n = (q – p) > (p – q) ? (q – p) : (p – q);

Views 11

Answer:

    int n = (q – p) > (p – q) ? (q – p) : (p – q)
⇒ int n = (19 - 5) > (5 - 19) ? (19 - 5) : (5 - 19)
⇒ int n = 14 > -14 ? 14 : -14
⇒ int n = 14 [∵ 14 > -14 is true so ? : returns 14]

Final value of n is 14

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.