Operators and Expressions – Part VIII (Comma Operator)

We have already talked about the arithmetic, assignment, increment, and decrement, relational, logical and conditional operators. Now in this post, we will see the comma operator.

Comma Operator:

#commaOperator
Comma Operator in C

The comma operator (, ) is used to permit different expressions to appear in situations where only one expression would be used. The expressions are separated by the comma operator. The separated expressions are evaluated from left to right and the type and value of the compound expression. Continue reading

Advertisements

Operators and Expressions – Part VII (Conditional Operator)

We have already talked about the arithmetic, assignment, increment, decrement, relational and logical operators. Now in this post, we will see about the conditional operator.

Conditional Operator:

Conditional Operator in C

Conditional operator ( ? : ) is a ternary operator and requires three expressions as operands. This is written as-

Test_Expression ? Expression1: Expression2 Continue reading

Operators and Expressions – Part VI (Logical Operator)

We have already talked about the arithmetic, assignment, increment, decrement and relational operators. Now in this post, we will see about the logical operator.

Logical Operator:

Logical Operator in C

An expression that combines two or more expressions is termed as a logical expression. For combining these expressions we use logical operators. These operators return 0 for false and 1 for true. The operands may be constants, variables or expressions. Continue reading

Operators and Expressions – Part V (Relational Operator)

We have already talked about the arithmetic, assignment, increment and decrement operators. Now in this post we will see about the relational operator.

Relational Operator:

Relational Operator in C

Relational operators are used to comparing values of two expressions depending on their relations. An expression that contains relational operator is called relational expression. If the relation is true, then the value of the relational expression is 1 and if the relation is false, the value of an expression is 0. Continue reading

Operators and Expressions – Part IV (Increment and Decrement Operator)

We have already talked about the arithmetic operators and assignment operators. Now in this post we will see about the increment and decrement operator.

Increment and Decrement Operator:

Increment and Decrement Operator in C

Increment (++) and decrement (–) operators are unary operators because they operate on only the single operand. The increment operator (++) increments the value of the variable by one and decrement operator (–) decrements the value of the variable by 1.

++x is equivalent to x = x + 1

–x is equivalent to x = x -1 Continue reading

Operators and Expressions – Part III (Assignment Operator)

We have already talked about the arithmetic operators. Now in this post, we will see what assignment operator is.

Assignment Operators:

Brief Introduction about Assignment Operator

A value can be stored in a variable with the use of assignment operator. The assignment operator “=” is used in assignment expressions and assignment statements. Continue reading

Operators and Expressions – Part II (Arithmetic Operators)

We have already known the general introduction about operators and expressions. Now we will go into detail of each of its type. Let’s begin with arithmetic operators.

Arithmetic Operators:

arithmetic operators in C
Arithmetic Operators in C

They are used for numeric calculations. They can be classified as unary operators and binary operators. Continue reading