Give some example of decrement operators.

void main()

{

int a=0;

printf(“%d”,a–);    output =0      // the output of this statement is 0.

printf(“%d”,a– – a–);      // here in this example  of decrement operator in first                                                            varible we dont do any changes we keep the value of                                                           first variable as well.but in the 2nd  variable same                                                                    variable the post decrement variable is executed.

=>0 – (-1)

=>0+1

=>1

output =1

printf(“%d”,a– + a–);

=>0 + (-1)

=>-1

=>output = -1.

 

}

Leave a Reply

Your email address will not be published. Required fields are marked *