Computer Science, asked by rachitkothadia98, 6 months ago

Write using ternary operator int m ; char x=’A’; if (x==’a’) m=’A’ else m=’a’; brainly

Answers

Answered by anindyaadhikari13
2

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

  • Write the following code using ternary Operator.

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

Given code,

int m;

char x='A';

if(x=='a')

m='A';

else

m='a';

The given code can be written using ternary operator as,

int m;

char ch='A';

m=(x=='a')?'A':'a';

Similar questions