3) Write the conditional statement for the following:
a) If value of (X +5) is greater than (2x+6) then increment the value of Y by 5 otherwise
decrement the value of Y by 6
Answers
Answered by
3
Answer:
Method one: using ternary operator
y=(x+5)>((2*x)+6)?y+5:y-6;
Method 2:using if-else block
if((x+5)>((2*x)+6))
y+=5;
else
y-=6;
MArk my answer brainliest if correct
follow me
Answered by
1
Question:-
- Write the conditional statement for the following.
Code:-
This can be done using two ways.
1st one,
y=(x+5>2*x+6)?y+5:y-6;
Or,
if(x+5>2*x+6)
y+=5;
else
y-=6;
Similar questions