ExamVeda
Login
Home
21
What is the result of the expression (10 + 2) / 2 in C?
Discuss
Answer & Solution
Answer: Option B
Solution:
In C, arithmetic expressions follow the order of operations (PEMDAS/BODMAS), where parentheses have the highest precedence. Therefore, the expression (10 + 2) is evaluated first, resulting in 12. Then, the division by 2 is performed, resulting in 12 / 2, which equals 6.

Option A (12) is incorrect because it represents the result of the expression inside the parentheses without considering the subsequent division.
Option C (7) is incorrect because it does not represent the correct result of the expression.
Option D (11) is incorrect because it doesn't consider the division by 2;
22
Which operator is used for inequality comparison in C?
Discuss
Answer & Solution
Answer: Option A
Solution:
In C, the != operator is used for inequality comparison. It checks if two values are not equal and returns true if they are not equal, otherwise, it returns false.

Option B (<>) is not a valid inequality comparison operator in C.
Option C (==) represents the equality operator, used to check if two values are equal, not for inequality comparison.
Option D (=) is the assignment operator, used to assign values to variables, not for comparison.
23
What is the result of the expression 2.5 + 2 in C?
Discuss
Answer & Solution
Answer: Option A
Solution:
In C, when you add two floating-point numbers, as in the expression 2.5 + 2, the result is a floating-point number. Therefore, the result is 4.5.

Option B (4) is incorrect because it represents an integer result, but the expression involves floating-point numbers.
Option C (2.7) is incorrect; it's not the result of the given expression.
Option D (2) is incorrect for the same reason as Option B; it represents an integer result, not a floating-point result.
24
What is the result of the expression 8 % 4 in C?
Discuss
Answer & Solution
Answer: Option A
Solution:
In C, the % (modulo) operator is used to calculate the remainder when one number is divided by another. In the expression 8 % 4, it calculates the remainder of dividing 8 by 4, which is 0.

Option B (4) is incorrect because it doesn't represent the remainder of the division.
Option C (2) is incorrect because it also doesn't represent the remainder; it represents half of the dividend.
Option D (8) is incorrect because it's the dividend itself, not the remainder of the division.
25
Which operator is used to perform a bitwise OR operation in C?
Discuss
Answer & Solution
Answer: Option B
Solution:
In C, the | operator is used to perform a bitwise OR operation. It performs a bitwise OR between corresponding bits of two integers. It returns a new integer where each bit is the result of ORing the corresponding bits of the operands.

Option A (&&) represents the logical AND operator, which is used for logical comparisons, not bitwise operations.
Option C (&) represents the bitwise AND operator, which performs bitwise AND operations, not bitwise OR.
Option D (||) represents the logical OR operator, used for logical comparisons, not bitwise operations.
26
What is the result of the expression 1 && 0 in C?
Discuss
Answer & Solution
Answer: Option B
Solution:
In C, the && operator is the logical AND operator. It returns 1 (TRUE) if both operands are true (non-zero), and 0 (FALSE) if any of the operands is false (zero). In this expression, the second operand is 0, which is false. Therefore, the result of the expression is 0 (FALSE).

Option A (1) is incorrect because the result of the expression is 0, not 1.
Option C (TRUE) represents the true value, but the result of the expression is 0 (FALSE).
Option D (FALSE) represents the false value, which is the correct result of the expression.
27
What is the result of the expression 5 * (1 + 2) - 3 in C?
Discuss
Answer & Solution
Answer: Option A
Solution:
In C, arithmetic expressions follow the order of operations (PEMDAS/BODMAS), where parentheses have the highest precedence. Therefore, the expression (1 + 2) inside the parentheses is evaluated first, resulting in 3. Then, the multiplication is performed: 5 * 3, which equals 15. Finally, the subtraction is performed: 15 - 3, which equals 12.

Option B (15) is incorrect because it represents the result of the multiplication but doesn't consider the subsequent subtraction.
Option C (10) is incorrect because it doesn't represent the correct result of the expression.
Option D (6) is incorrect because it doesn't consider both the multiplication and subtraction; the correct result is 12.
28
Which operator is used to perform a bitwise XOR operation in C?
Discuss
Answer & Solution
Answer: Option D
Solution:
In C, the ^ operator is used to perform a bitwise XOR (exclusive OR) operation. It performs a bitwise XOR between corresponding bits of two integers. It returns a new integer where each bit is the result of XORing the corresponding bits of the operands.

Option A (&&) represents the logical AND operator, used for logical comparisons, not bitwise operations.
Option B (||) represents the logical OR operator, used for logical comparisons, not bitwise operations.
Option C (&) represents the bitwise AND operator, used for bitwise AND operations, not bitwise XOR.
29
What is the result of the expression (6 + 3) / 0 in C?
Discuss
Answer & Solution
Answer: Option D
Solution:
In C, dividing a number by zero is undefined and leads to a runtime error. The expression (6 + 3) / 0 will result in a runtime error because dividing by zero is not allowed in mathematics or in C programming.
30
What is the result of the expression 5 / 2.0 in C?
Discuss
Answer & Solution
Answer: Option B
Solution:
In C, when you divide an integer by a floating-point number, the result is a floating-point number. In this expression, 5 is an integer, and 2.0 is a floating-point number. When you perform the division, 5 / 2.0, it results in 2.5.

Option A (2) is incorrect because it represents an integer result, but the expression involves a floating-point division.
Option C (2.0) is also incorrect because it represents the result as a floating-point number, but the correct result is 2.5.
Option D (3) is incorrect because it doesn't consider the decimal part of the result; the correct result is 2.5.