405 views
0 votes
0 votes
void main(){

int i=-1;

+i;

printf("%d %d",i,+i);

}

1 Answer

Best answer
3 votes
3 votes

Output of above program:-  '-1 -1'

Because

As per the C90 standard in 6.3.3.3:-

"The result of the unary + operator is the value of its operand. The integral promotion is performed on the operand. and the result has the promoted type."

Also, +i; does nothing other than returning the value of i which is not used anywhere. 

selected by