resh_personal wrote:
>
> WHY WE SHOULD USE THE SYMBOL? WHAT IS THE USE OF IT? THERE ARE SO MANY
> SYMBOLS IN C WHAT IS THE NECESSARY TO CHOOSE THE ?
>
>  
UNDERSTANDING THE ? OPERATOR
   
C contains one ternary operator: the ?.  A ternary operator requires 
three operands.
The ? operator is used to replace statements such as:

if(condition) var = exp1;
else var = exp2;

The general form of the ? operator is

    var = condition ? exp1: exp2;

Here, condition is an expression that evaluates to true or false.  If it 
is true, var is
assigned the value of exp1.  If it is false, var is assigned the value 
of exp2.  The
reason for the ? operator is that a C compiler can produce more 
efficient code
using it instead of the equivalent if/else statement.

Reply via email to