using conditional operator write equivalent expression for the following
1) F=0.5 if x=30 otherwise 0
2) Print "Even" if x is an even number otherwise print "Odd"
Answers
Answered by
7
1) using ternary operator..
F=(x=30)?0.5:0
2)you can use ternary operator but for not making it complex..use if else....
if( x %2 == 0 )
{ SOPln(" Even");
}
else
{SOPln( "Odd");
}
Similar questions
English,
6 months ago
Social Sciences,
6 months ago
Accountancy,
6 months ago
Science,
11 months ago
Chemistry,
11 months ago
Math,
1 year ago
Math,
1 year ago