Computer Science, asked by PALAKJAISWAL79, 7 months ago

plz answer fast!!! don't write irrelevant answers or else I'll report. ​plz

Attachments:

Answers

Answered by anindyaadhikari13
1

\star\:\:\:\sf\large\underline\blue{Question:-}

  • Write the following code using ternary operator.

\star\:\:\:\sf\large\underline\blue{Solution:-}

Given code,

double num=5.5;

String result;

if(num>0.0)

{

result="positive";

}

else

{

result="negative.";

}

The above code can be written using ternary operator as,

double num=5.5;

String result=(num>0.0)?"positive":"negative";

Answered by rubal9587
0

Answer:

Given code,

double num=5.5;

String result;

if(num>0.0)

{

result="positive";

}

else

{

result="negative.";

}

The above code can be written using ternary operator as,

double num=5.5;

String result=(num>0.0)?"positive":"negative";

Similar questions