
Other operators such as ternary operator ?:, reference operator &, dereference operator * and member selection operator -> will be discussed in later tutorials. Printf("Size of char=%lu byte\n",sizeof(d)) Printf("Size of double=%lu bytes\n",sizeof(c)) Printf("Size of float=%lu bytes\n",sizeof(b)) Printf("Size of int=%lu bytes\n",sizeof(a)) The sizeof is a unary operator that returns the size of data (constants, variables, array, structure, etc). Other OperatorsĬomma operators are used to link related expressions together.

Visit bitwise operator in C to learn more. (a = b) & (c 5) evaluates to 1 because both operands (a = b) and (c > b) is 1 (true). Printf("(a = b) & (c > b) is %d \n", result) If c = 5 then, expression !(c=5) equals to 0.Įxample 5: Logical Operators // Working of logical operators If c = 5 and d = 2 then, expression ((c=5) || (d>5)) equals to 1. 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. Write a program that adds the following three words. CODE xchg ah, al exchange 8-bit regs xchg ax, bx exchange 16-bit regs.

Suppose a = 5.0, b = 2.0, c = 5 and d = 2. Data Transfer Instructions Addition and Subtraction Addressing Modes Jump and Loop Instructions. 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.
