Computer Science, asked by sohanmondal, 1 year ago

predict the ouutput int c=(3 is lesser than 4)? 3*4:3+4​

Answers

Answered by ridhimakh1219
13

The value 12 is assigned to variable c

Explanation:

Java program to use conditional operator

public class Main

{

public static void main(String[] args) {

  int c;

         c = (3 < 4) ? 3*4 : 3+4;

         System.out.println("Value of c is: " + c);

}

}

Output

Value of c is: 12

Syntax of conditional operator

variable = (expression)? value if true: value if false

Example:

case 1

c = (3 < 4) ? 3*4 : 3+4;

if the expression 3 < 4 evaluates to true then 3*4 = 12 will assigned to variable c means c = 12

case 2

c = (3 > 4) ? 3*4 : 3+4;

if the expression 3 < 4 evaluates to false then 3+4 = 7 will assigned to variable c means c = 7

Answered by roshansrisai
0

Answer:

12....

...

....

.............

Similar questions