Relational operators are used in decision making and loops. If the relation is true, it returns 1 if the relation is false, it returns value 0. The most common assignment operator is = OperatorĮxample 3: Assignment Operators // Working of assignment operatorsĪ relational operator checks the relationship between two operands. Visit this page to learn more about how increment and decrement operators work when used as postfix.Īn assignment operator is used for assigning a value to a variable. These two operators can also be used as postfixes like a++ and a. Here, the operators ++ and - are used as prefixes. Example 2: Increment and Decrement Operators // Working of increment and decrement operators These two operators are unary operators, meaning they only operate on a single operand. Increment ++ increases the value by 1 whereas decrement - decreases the value by 1. Either one of the operands is a floating-point numberĬ programming has two operators increment ++ and decrement - to change the value of an operand (constant or variable) by 1. The % operator can only be used with integers. ![]() ![]() When a=9 is divided by b=4, the remainder is 1. The modulo operator % computes the remainder. The compiler neglects the term after the decimal point and shows answer 2 instead of 2.25. ![]() ![]() It is because both the variables a and b are integers. The operators +, - and * computes addition, subtraction, and multiplication respectively as you might have expected.
0 Comments
Leave a Reply. |