Elements of C - Short
Questions and Answers. This is the 3rd
post about 2nd Year | ICS Part-II Computer Science
Chapter No.9: (Elements of C) | Short Questions and
Answers.
The following objective
questions (short questions and answers) are very important for the
final examinations of all Boards.
Chapter No.9: Elements of C
Short Questions and Answers - 3
Q.1: Define the statement j += 5; ?
Answer:
The statement j += 5 increases the value of j by 5. For example, if value of j = 10 then the value of j = 15 after the execution of above statement.
Q.2: What is the operator’s precedence?
Answer:
An operator’s precedence determines its order of evaluation in an expression.
Q.3: Write the order of operator’s precedence from highest to lowest?
Answer:
The order of operator’s precedence from highest to lowest is as under:
Q.4: What are unary operators?
Answer:
The unary operators are those operators that have just one operand. The example of unary operators is logical NOT, increment and decrement operator.
Q.5: What are binary operators?
Answer:
The binary operators are those operators that have two operands. The example of binary operators is arithmetic operators, relational operators, logical AND, logical OR and the assignment operator.
Q.5: What is ternary operator?
Answer:
The ternary operator is an operator that has three operands or arguments. The example of ternary operator in C language is conditional operator.
Q.6: Define the working with division operator?
Answer:
The manipulation of division operation is slightly different from other arithmetic operations in C. when the divisor and the dividend both are integers, the fractional part of the quotient is truncated.
Q.7: Differentiate between 7.0 / 2.0 and 7 / 2 statements?
Answer:
The result value of 7.0 / 2.0 is 3.5 but the value of 7 / 2 is the integral part of the result i.e. 3. The fractional part of the result i.e. .5 is truncated.
Q.8: What are the values of a and b after execution? Let a
and b be two variables of type double and int respectively:
Answer:
Let,
a = 5 * 0.5;
b = 5 * 0.5;
After execution:
a = 2.5
b = 2
Q.9: What are the comments?
Answer:
The comments are used increase the readability of the program. With comments, informative notes are inserted in the program’s code, which helps in debugging and modifying the program. There are two types of comments in C:
Q.10: differentiate between single-line comments and multi-line comments?
Answer:
// This is an example of single-line comment.
/*
Line – 1: This is an example of multi-line comments.
.
.
.
Line – N: This is an example of multi-line comments.
*/
Answer:
The statement j += 5 increases the value of j by 5. For example, if value of j = 10 then the value of j = 15 after the execution of above statement.
Answer:
An operator’s precedence determines its order of evaluation in an expression.
Answer:
The order of operator’s precedence from highest to lowest is as under:
- ! (logical NOT operator)
- *, /, % (modulus or remainder operator)
- +, -
- <, <=, >, >=
- == (equal), != (not equal)
- && (logical AND operator)
- || (logical OR operator)
- = (assignment operator)
Answer:
The unary operators are those operators that have just one operand. The example of unary operators is logical NOT, increment and decrement operator.
Answer:
The binary operators are those operators that have two operands. The example of binary operators is arithmetic operators, relational operators, logical AND, logical OR and the assignment operator.
Answer:
The ternary operator is an operator that has three operands or arguments. The example of ternary operator in C language is conditional operator.
Answer:
The manipulation of division operation is slightly different from other arithmetic operations in C. when the divisor and the dividend both are integers, the fractional part of the quotient is truncated.
Answer:
The result value of 7.0 / 2.0 is 3.5 but the value of 7 / 2 is the integral part of the result i.e. 3. The fractional part of the result i.e. .5 is truncated.
Answer:
Let,
a = 5 * 0.5;
b = 5 * 0.5;
After execution:
a = 2.5
b = 2
Answer:
The comments are used increase the readability of the program. With comments, informative notes are inserted in the program’s code, which helps in debugging and modifying the program. There are two types of comments in C:
- Single line comments
- Multiline comments
Answer:
- Single-line comments:
// This is an example of single-line comment.
- Multi-line comments:
/*
Line – 1: This is an example of multi-line comments.
.
.
.
Line – N: This is an example of multi-line comments.
*/
Post a Comment
Your feedback is highly appreciated and will help us to improve. So, please give your good suggestions.