Interview questions on C Language operators
1. What is an operand?
The data items on which operators act upon are called operands. Some operators require two operands while others require only one operand. Most operators allow the individual operands to be expressions. A few operators permit only single variable as operand.
2. What is an Operator?
An operator is a symbol that operates on a certain data type and produces the output as the result of the operation.
3. Explain about precedence of C Operators?
The operators in C are grouped hierarchically according to their order of evaluation known as precedence. The operator precedence determines the grouping of terms in an expression. This affects how an expression is evaluated. Certain operators have higher precedence than others. For example, the multiplication operator has higher precedence than the addition operator.
The operators *, / and % have higher precedence than + and . In other words, multiplication, division and remainder operations will be carried out before addition and subtraction. Arithmetic operators *,/ and % are under one precedence group and +, are under another precedence group.
4. What is associativity of the operators in C?
The order in which consecutive operations within the same precedence group are carried out is known as associativity. Within each of the precedence groups, the associativity is left to right. In other sense, consecutive addition and subtraction operations are carried out from left to right, as are consecutive multiplication, division and remainder operations.
5. How many categories of operators are there in C?
There are 3 categories of operators are there in C.
1. Unary Operators: A unary operator is an operator, which operates on one operand.
2. Binary Operators: A binary operator is an operator, which operates on two operands.
3. Ternary Operators: A ternary operator is an operator, which operates on three operands.
6. Explain about Unary Operators in C?
C includes a class of operators that act upon a single operand to produce a new value. Such operators are known as unary operators. A Unary operator usually precedes their single operands, though some unary operators are written after their operands. The most common unary operator is unary minus, where a minus sign precedes a numerical constant, a variable or an expression.
Following are the unary operators available under C:
! & *  + ~
7. What are Increment and Decrement Operators?
Increment and Decrement Operators also fall under the broad category or unary operators but are quite distinct than unary minus. The increment and decrement operators are very useful in C language. They are extensively used in for and while loops.
The syntax of these operators is given below.
++
++
–
–
The ++ operator increments the value of the variable by one, whereas the  operator decrements the value of the variable by one. These operators can be used in either the postfix or prefix notation as follows:
Postfix: a++ or a–
Prefix: ++a or a
8. What is sizeof operator?
This is another unary operator. This operator returns the size of its operand in bytes. This operator always precedes its operand. The operand may be an expression or it may be a cast.
Ex:
sizeof (x);
sizeof (y);
9. How many types of operators are there in C?
C language supports following type of operators.
1. Arithmetic Operators.
2. Logical (or Relational) Operators.
3. Bitwise Operators.
4. Assignment Operators.
5. Misc Operators.
10. What is arithmetic operator?
The arithmetic operator is a binary operator, which requires two operands to perform its operation of arithmetic. Following are the arithmetic operators that are available in C:
Operator Description
+ Addition
 Subtraction
/ Division
* Multiplication
% Modulo or remainder
11. What is cast operator?
The name of data type to which the conversion is to be made is enclosed in parentheses and placed directly to the left of the value to be converted is called cast operator.
The example of type casting is as follows:
int a=17;
float b;
b=(float)a+ 11.0;
The cast operator converts the value of int a to its equivalent float representation before the addition of 11.0 is carried out.
12. What is logical (or relational) operator?
A logical operator is used to compare or evaluate logical and relational expressions. There are three logical operators available in the C language.
Operator Meaning
&& Logical AND
 Logical OR
! Logical NOT
13. Explain about logical AND and logical OR operator?
The result of a logical AND operation will be true only if both operands are true, whereas the result of a logical OR operation will be true if either operand is true or if both operands are true.
14. Explain about Logical NOT operator?
'C' also includes the unary operator logical NOT (!’) that negates the value of a logical expression. This is known as logical negation or logical NOT operator. The associativity of negation operator is right to left.
15. What are Relational operators in C?
Relational operators are symbols that are used to test the relationship between two variables, or between a variable and a constant. The test for equality is made by means of two adjacent equal signs with no space separating them.
‘C’ has six relational operators as follows:
> greater than
< less than
!= not equal to
>= greater than or equal to
>= less than or equal to
These operators all fall within the same precedence group, which is lower than the unary and arithmetic operators. The associativity of these operators is lefttoright.
16. What is Assignment Operator in C?
An assignment operator (=) is used to assign a constant or a value of one variable to another. There are several different assignment operators in C. All of them are used to form assignment expression, which assign the value of an expression to an identifier. The most commonly used assignment operator is =. The assignment expressions that make use of this operator are written in the form:
identifier=expression
Where identifier generally represents a variable and expression represents a constant, a variable or a more complex expression.
17. What is the difference between Assignment operator and the equality operator?
Assignment operator = and the equality operator == are distinctly different. The assignment operator is used to assign a value to an identifier, whereas the equality operator is used to determine if two expressions have the same value. These two operators cannot be used in place of one another.
18. What are the additional assignment operators in C?
‘C’ also contains the five additional assignment operators: They are
+=, =, *=, /=, and %=.
19. What is Conditional Operator in C?
A conditional operator checks for an expression, which returns either a true or a false value. If the condition evaluated is true, it returns the value of the true section of the operator, otherwise it returns the value of the false section of the operator. The conditional operator has its own precedence. The associativity is righttoleft.
20. What is conditional expression?
An expression that makes use of the conditional operator is called a conditional expression.
A conditional expression is written as follows:
Expression 1? expression 2 (True) : expression 3 (False)
21. What is Bitwise Operator?
Bitwise operator works on bits and it performs bit by bit operation.
The Bitwise operators supported by C language are as follows:
23. Explain about different Operators Categories?
All the operators can be categorized into following categories:
1. Postfix operators, which follow a single operand.
2. Unary prefix operators, which precede a single operand.
3. Binary operators, which take two operands and perform a variety of arithmetic and logical operations.
4. The conditional operator (a ternary operator), which takes three operands and evaluates either the second or third expression, depending on the evaluation of the first expression.
5. Assignment operators, which assign a value to a variable.
6. The comma operator, which guarantees lefttoright evaluation of commaseparated expressions.
24. When should a type cast not be used?
Type cast can be done when we want to convert the data in one type to another type.
Ex: In order to change the data from double data type to integer data type. But it is not used to convert integer data type to double data type.
#include<stdio.h>
#include<conio.h>
main()
{
double d=10.434;
clrscr();
int a=(double)d;
printf("%ld",d);
printf("%d",a);
getch();
}
25. Which bit wise operator is suitable for turning off a particular bit in a number?
The bitwise AND operator is suitable for turning off a particular bit in a number.
26. What is a modulus operator? What are the restrictions of a modulus operator?
A Modulus Operator % returns the remainder of any Integer Division.
It doesn’t return any Float Value (Only the integer Value).
The restriction is that this Operator can be operated with Integers only.
27. Which bit wise operator is suitable for checking whether a particular bit is on or off?
The bitwise AND operator is suitable for checking whether a particular bit is on or off.
28. Which bit wise operator is suitable for putting on a particular bit in a number?
The bitwise OR operator is suitable for putting on a particular bit in a number.
30. What is Ternary operator in C?
C ternary operator is sometimes called conditional operator. The Ternary operator is unusual in that it takes three operands.
Operator Description
? : If Condition is true? Then evaluate Expression 1 : Otherwise evaluate Expression 2

Interview Questions on C Language Overview
Interview Questions on C Language Data Types
Interview Questions on C Language Variables
Interview Questions on C Language Constants
Interview Questions on C Language Conditional Statements
Interview Questions on C Language Loop Statements
Interview Questions on C Language Builtin Functions
Interview Questions on C Language User defined Functions
Interview Questions on C Language Pointers
Working with Files
Working with Databases
Interview Questions on C Data Structures
Comments
Programming Examples
1. What is an operand?
The data items on which operators act upon are called operands. Some operators require two operands while others require only one operand. Most operators allow the individual operands to be expressions. A few operators permit only single variable as operand.
2. What is an Operator?
An operator is a symbol that operates on a certain data type and produces the output as the result of the operation.
3. Explain about precedence of C Operators?
The operators in C are grouped hierarchically according to their order of evaluation known as precedence. The operator precedence determines the grouping of terms in an expression. This affects how an expression is evaluated. Certain operators have higher precedence than others. For example, the multiplication operator has higher precedence than the addition operator.
The operators *, / and % have higher precedence than + and . In other words, multiplication, division and remainder operations will be carried out before addition and subtraction. Arithmetic operators *,/ and % are under one precedence group and +, are under another precedence group.
4. What is associativity of the operators in C?
The order in which consecutive operations within the same precedence group are carried out is known as associativity. Within each of the precedence groups, the associativity is left to right. In other sense, consecutive addition and subtraction operations are carried out from left to right, as are consecutive multiplication, division and remainder operations.
5. How many categories of operators are there in C?
There are 3 categories of operators are there in C.
1. Unary Operators: A unary operator is an operator, which operates on one operand.
2. Binary Operators: A binary operator is an operator, which operates on two operands.
3. Ternary Operators: A ternary operator is an operator, which operates on three operands.
6. Explain about Unary Operators in C?
C includes a class of operators that act upon a single operand to produce a new value. Such operators are known as unary operators. A Unary operator usually precedes their single operands, though some unary operators are written after their operands. The most common unary operator is unary minus, where a minus sign precedes a numerical constant, a variable or an expression.
Following are the unary operators available under C:
! & *  + ~
7. What are Increment and Decrement Operators?
Increment and Decrement Operators also fall under the broad category or unary operators but are quite distinct than unary minus. The increment and decrement operators are very useful in C language. They are extensively used in for and while loops.
The syntax of these operators is given below.
++
++
–
–
The ++ operator increments the value of the variable by one, whereas the  operator decrements the value of the variable by one. These operators can be used in either the postfix or prefix notation as follows:
Postfix: a++ or a–
Prefix: ++a or a
8. What is sizeof operator?
This is another unary operator. This operator returns the size of its operand in bytes. This operator always precedes its operand. The operand may be an expression or it may be a cast.
Ex:
sizeof (x);
sizeof (y);
9. How many types of operators are there in C?
C language supports following type of operators.
1. Arithmetic Operators.
2. Logical (or Relational) Operators.
3. Bitwise Operators.
4. Assignment Operators.
5. Misc Operators.
10. What is arithmetic operator?
The arithmetic operator is a binary operator, which requires two operands to perform its operation of arithmetic. Following are the arithmetic operators that are available in C:
Operator Description
+ Addition
 Subtraction
/ Division
* Multiplication
% Modulo or remainder
11. What is cast operator?
The name of data type to which the conversion is to be made is enclosed in parentheses and placed directly to the left of the value to be converted is called cast operator.
The example of type casting is as follows:
int a=17;
float b;
b=(float)a+ 11.0;
The cast operator converts the value of int a to its equivalent float representation before the addition of 11.0 is carried out.
12. What is logical (or relational) operator?
A logical operator is used to compare or evaluate logical and relational expressions. There are three logical operators available in the C language.
Operator Meaning
&& Logical AND
 Logical OR
! Logical NOT
13. Explain about logical AND and logical OR operator?
The result of a logical AND operation will be true only if both operands are true, whereas the result of a logical OR operation will be true if either operand is true or if both operands are true.
14. Explain about Logical NOT operator?
'C' also includes the unary operator logical NOT (!’) that negates the value of a logical expression. This is known as logical negation or logical NOT operator. The associativity of negation operator is right to left.
15. What are Relational operators in C?
Relational operators are symbols that are used to test the relationship between two variables, or between a variable and a constant. The test for equality is made by means of two adjacent equal signs with no space separating them.
‘C’ has six relational operators as follows:
> greater than
< less than
!= not equal to
>= greater than or equal to
>= less than or equal to
These operators all fall within the same precedence group, which is lower than the unary and arithmetic operators. The associativity of these operators is lefttoright.
16. What is Assignment Operator in C?
An assignment operator (=) is used to assign a constant or a value of one variable to another. There are several different assignment operators in C. All of them are used to form assignment expression, which assign the value of an expression to an identifier. The most commonly used assignment operator is =. The assignment expressions that make use of this operator are written in the form:
identifier=expression
Where identifier generally represents a variable and expression represents a constant, a variable or a more complex expression.
17. What is the difference between Assignment operator and the equality operator?
Assignment operator = and the equality operator == are distinctly different. The assignment operator is used to assign a value to an identifier, whereas the equality operator is used to determine if two expressions have the same value. These two operators cannot be used in place of one another.
18. What are the additional assignment operators in C?
‘C’ also contains the five additional assignment operators: They are
+=, =, *=, /=, and %=.
19. What is Conditional Operator in C?
A conditional operator checks for an expression, which returns either a true or a false value. If the condition evaluated is true, it returns the value of the true section of the operator, otherwise it returns the value of the false section of the operator. The conditional operator has its own precedence. The associativity is righttoleft.
20. What is conditional expression?
An expression that makes use of the conditional operator is called a conditional expression.
A conditional expression is written as follows:
Expression 1? expression 2 (True) : expression 3 (False)
21. What is Bitwise Operator?
Bitwise operator works on bits and it performs bit by bit operation.
22. What are the Bitwise operators
supported by C language?
The Bitwise operators supported by C language are as follows:
Operator

Description

&

Binary
AND Operator copies a bit to the result if it exists in both operands.



Binary
OR Operator copies a bit if it exists in either operand.

^

Binary
XOR Operator copies the bit if it is set in one operand but not both.

~

Binary
Ones Complement Operator is unary and has the effect of 'flipping' bits.

<<

Binary
Left Shift Operator. The left operands value is moved left by the number of
bits specified by the right operand.

>>

Binary
Right Shift Operator. The left operands value is moved right by the number of
bits specified by the right operand.

23. Explain about different Operators Categories?
All the operators can be categorized into following categories:
1. Postfix operators, which follow a single operand.
2. Unary prefix operators, which precede a single operand.
3. Binary operators, which take two operands and perform a variety of arithmetic and logical operations.
4. The conditional operator (a ternary operator), which takes three operands and evaluates either the second or third expression, depending on the evaluation of the first expression.
5. Assignment operators, which assign a value to a variable.
6. The comma operator, which guarantees lefttoright evaluation of commaseparated expressions.
24. When should a type cast not be used?
Type cast can be done when we want to convert the data in one type to another type.
Ex: In order to change the data from double data type to integer data type. But it is not used to convert integer data type to double data type.
#include<stdio.h>
#include<conio.h>
main()
{
double d=10.434;
clrscr();
int a=(double)d;
printf("%ld",d);
printf("%d",a);
getch();
}
25. Which bit wise operator is suitable for turning off a particular bit in a number?
The bitwise AND operator is suitable for turning off a particular bit in a number.
26. What is a modulus operator? What are the restrictions of a modulus operator?
A Modulus Operator % returns the remainder of any Integer Division.
It doesn’t return any Float Value (Only the integer Value).
The restriction is that this Operator can be operated with Integers only.
27. Which bit wise operator is suitable for checking whether a particular bit is on or off?
The bitwise AND operator is suitable for checking whether a particular bit is on or off.
28. Which bit wise operator is suitable for putting on a particular bit in a number?
The bitwise OR operator is suitable for putting on a particular bit in a number.
29. What are Misc Operators in C?
The Misc operators supported by C
Language are as follows:
Operator

Description

Sizeof()

Returns the size of an variable.

&

Returns the address of an variable.

*

Pointer to a variable.

? :

Conditional Expression.

30. What is Ternary operator in C?
C ternary operator is sometimes called conditional operator. The Ternary operator is unusual in that it takes three operands.
Operator Description
? : If Condition is true? Then evaluate Expression 1 : Otherwise evaluate Expression 2

C Language Interview Questions
Interview Questions on C Language Overview
Interview Questions on C Language Data Types
Interview Questions on C Language Variables
Interview Questions on C Language Constants
Interview Questions on C Language Conditional Statements
Interview Questions on C Language Loop Statements
Interview Questions on C Language Builtin Functions
Interview Questions on C Language User defined Functions
Interview Questions on C Language Pointers
Working with Files
Working with Databases
Interview Questions on C Data Structures
Comments
Programming Examples
0 comments:
Post a Comment