Computer Science, asked by chandraaditya690, 5 months ago

Given the following code fragment :
if (a
System.out.println (“Zero");
if (1
System.out.println("One");
if (2)
System.out.println("Two");
if (3)
System.out.println("Three");
write an alternative code that saves on number of comparisons.​

Answers

Answered by rajjanu18121982
13

Answer:

Here is the answer ..............

Explanation:

ANSWER = if ( a == 0 )

System . out . println ( "zero" ) ,

else if ( a == 1 )

System . out . println ( "one" ) ,

else if ( a == 2 )

System . out . println ( "two" ) ,

else if ( a == 3 )

System . out . println ( "three" ) ....

I hope it helpd you ...............

Please like and follow me...............

Similar questions