0
How to use condition operator in c lang
i used its as (c=='+')?printf("%d",a+b): continue; (c=='-')?printf("%d",a-b): continue; (c=='*')?printf("%d",a*b): continue; so is this wrong........ plz rply its urgent
3 Answers
+ 3
Agreeing with Programanta ludanto, you should probably use a switch statement instead of the ternary condition operator.
+ 2
(condition) ? a : b
The a and b must be the same types.
So you should use if or switch statement like below.
switch(c)
{
case '+':
print(.....);
break;
case '-':
.....
case '*':
.....
default:
continue;
}
0
buddy i know that but still i want to use condition operator so plz suggest me a way