- What is conditional operator and it's syntax in C.
- What is the logical operator in C.
- What is the bitwise operator in C.
What is conditional operator and it's syntax in C
Conditional Operator is a powerful Operator which can be used to implement if-then-else type of logic. This operator is also known as ternary operator and it takes three arguments in the following form.
Conditional_Expression ? Expression_One : Expression_Two;Ternary Operator will execute Expression_One if Conditional_Expression is true, otherwise it execute Expression_Two.
Ternary Operator is similar to if-else decision block as it evaluates only one code block depending on the result of Conditional_Expression.
int X = 25; int Y = (X > 20 ? 1 : 2);As X > 20, So after above statement Y's value becomes 1.
What is assignment operators in C
Assignment Operators of C is used to assign a value to a variable. "=" is called simple arithmetic operator of C, it assigns values from right side operands(R value) to left side operand (L value). The general syntax of assignment operator is:
variable_name = expression;For Example
value = 1234;
value = 4/2;
What is the bitwise operator in C
C is a middle level language, it support many operations which can be performed in assembly language like operations on bits. Bitwise operators performs bit-by-bit operations on operands. There are six bitwise operators supported by C programming language.
- Bitwise OR Operator(|)
- Bitwise AND Operator(&)
- NOT Operator(One's Complement)(~)
- Bitwise Exclusive OR Operator(^)
- Right Shift Operator(>>)
- Left Shift Operator(<<)