Home > Electronics Tutorials > C Language Tutorial > Operators - Unary and Prefix

C Language Programming Library Reference Guide

Operators - Unary and Prefix

Prefix operators are operators that are prefixed to an expression. ++operand;
This causes the value of the operand to be incremented by 1. Its new value is then returned. --operand;
This is the same but the value of the operand is decremented by 1. !operand
Returns the logical NOT operation on the operand. A true operand returns false, a false operand returns true. Also known as the bang operand. ~operand
Returns the compliment of the operand. The returned value is the operand with its bits reversed (1's become 0's, 0's become 1's).

Examples:

int bart=7;
printf("%i",--bart);

This outputs the number 6. The value of bart is now 6.

int lisa=1;
printf("%i",!lisa);

This outputs 0 (false).
Note: To report broken links or to submit your projects, tutorials please email to Webmaster

Discover

     more......