Computer Science, asked by rajeshwarivaangadi, 7 months ago

4) Write the conditional operator (ternary operator) for the conditional statement.
if( m==0) System.out.println("hello");
else System.out.println (“Good Day");​

Answers

Answered by CoderRishav
1

Answer:

String res = m == 0?"hello":"Good Day";

Sopln(res)

hope this will be helpful for you :)

Answered by anindyaadhikari13
1

Question:-

  • Write the following statement using ternary operator.

Solution:-

Given code,

if(m==0)

System.out.println("Hello.");

else

System.out.println("Good Day. ");

The given code can be written using ternary operator as,

System.out.println((m==0)?"Hello.":"Good Day. ");

Similar questions