Computer Science, asked by arpitaagrahari346, 5 months ago

b. Rewrite the following using Ternary operator-
if(marks>200)
char res='P';
else
char res='F':​

Answers

Answered by Oreki
4

Using Ternary Operator:

char res = (marks > 200) ? 'P' : 'F';

Answered by anindyaadhikari13
3

Question:-

Rewrite the following using Ternary Operator.

Solution:-

Given code,

char res;

if(marks>200)

res='P';

else

res = 'F';

The given code can be written using ternary operator as,

char res=(marks>200)?'P':'F';

Similar questions