b. Rewrite the following using Ternary operator-
if(marks>200)
char res='P';
else
char res='F':
Answers
Answered by
4
Using Ternary Operator:
char res = (marks > 200) ? 'P' : 'F';
Answered by
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