Sunday, 4 June 2023

Operators and Expressions in C

What are an operators and expressions?

An operator states an operation to be performed that relent a value. Several operators to form an expression can fix the constants, variables. An operand is a information item on which an operator behave. Some operators need two operands, while others behave upon only one operand. C includes a big number of operators that fall under several different categories, which are as follows

C language, operators, Expressions in C
C language operators and expressions image-1

1.       Arithmetic operators

2.       Bitwise operators

3.       Comma operator

4.       Logic operators

5.       Relational operators

6.       Sizeof operator

7.       Increment and decrement operators

8.       Assignment operators

9.       Conditional operator

10.   Other operators

 

1.1   Arithmetic operators

Arithmetic operators are used for numeric calculations. They are of two types –

1.       Unary arithmetic operators

2.       Binary arithmetic operators

 

1.2   Assignment operator

A worth can be set aside in a not consistent with the use of assignment operator. This assignment operators “=” is used in assignment statements and assignment expressions.

 

1.3   Increment and Decrement operators

C has two functional operators increment (++) and decrement (--). These are unary operators as they operate on a single operand.

1.4   Relational operators

Relational operators are functional to collate values of two expressions be controlled on their relations. An expression that carries relational operators is called relational expressions. if the relation is false then the value of expression is 0 and If the relation is true then the value of relational expression is 1.

 

1.5   Logical or Boolean operators

An expression that integrates two or more expressions is termed as a logical expression. For merge these expressions we use logical operators.

1.6   Conditional operator

Conditional operator is a ternary operator which requires three operands expressions.

This is written as – TestExpression ? Expression1 : expression 2

Here first the expression a>b is evaluated, if the worth is true then the value of variable as the value of conditional expression otherwise the value of b becomes the value of conditional expression.

1.7   Comma operator

The comma operator (,) is used to permit dissimilar expressions to look in situations where only one expression would be used. The comma operators break up the expressions. The separated expressions are assessing from left to right and the type and value of the rightmost expression is the type and value of the compound expression.

1.8   Sizeof operator

Sizeof is a unary operator. This operator gives the size of its operand it terms of bytes.

1.9   Bitwise operators

C has the capacity to support the manipulation of data at the bit level. Bitwise operators operate on integers only.


Computer stuff kit tricks of Topics 48.