ExamVeda
Login
Home
1
What is the result of the expression 5 + 7 * 2 in C?
Discuss
Answer & Solution
Answer: Option A
Solution:
In C and many programming languages, mathematical expressions follow the operator precedence rules. Multiplication (*) and division (/) have higher precedence than addition (+) and subtraction (-).

So, when evaluating the expression "5 + 7 * 2," the multiplication is performed before addition:

5 + (7 * 2) = 5 + 14 = 19

Therefore, the result of the expression "5 + 7 * 2" in C is Option A: 19.
2
Which operator is used for logical OR in C?
Discuss
Answer & Solution
Answer: Option D
Solution:
In C, the || operator is used for logical OR. It returns true (1) if at least one of the operands is true, otherwise, it returns false (0).

Option A (&&) represents the logical AND operator.
Option B (|) represents the bitwise OR operator.
Option C (&) represents the bitwise AND operator in C.

Therefore, Option D (|| ) is the correct answer.
3
What does the ++ operator do in C when applied to a variable?
Discuss
Answer & Solution
Answer: Option B
Solution:
When the ++ operator is applied to a variable in C, it increments the value of the variable by 1.

Option A (Decrements by 1) is incorrect as the ++ operator increases the value.
Option C (Doubles the value) is incorrect as the ++ operator adds 1, not doubles the value.
Option D (Leaves it unchanged) is incorrect as the ++ operator explicitly increments the variable's value by 1.
4
Which operator is used for modulus division in C?
Discuss
Answer & Solution
Answer: Option A
Solution:
In C, the % (modulo) operator is used for modulus division. It calculates the remainder when one number is divided by another.

Option B (/) is incorrect as it represents regular division.
Option C (*) is incorrect as it represents multiplication.
Option D (&) is incorrect as it represents the bitwise AND operator, not modulus division.
5
What is the result of the expression 8 / 3 in C?
Discuss
Answer & Solution
Answer: Option A
Solution:
In C, when you perform integer division, as in the expression 8 / 3, it results in the quotient without any decimal places. Therefore, the result is 2.

Option B (2.67) is incorrect as it would be the result of floating-point division.
Option C (3) is incorrect because it would be the result of rounding up in floating-point division.
Option D (3.5) is incorrect because it would be the result of floating-point division.
6
What is the order of precedence of the arithmetic operators in C?
Discuss
Answer & Solution
Answer: Option C
Solution:
In C, the arithmetic operators have a specific order of precedence. Multiplication has the highest precedence, followed by division, and then addition and subtraction. This order ensures that expressions are evaluated in the correct mathematical order.
7
What is the result of the expression 10 - 5 * 2 in C?
Discuss
Answer & Solution
Answer: Option C
Solution:
In C, arithmetic expressions follow the order of precedence, where multiplication and division have higher precedence than addition and subtraction. Therefore, in the expression 10 - 5 * 2, the multiplication (5 * 2) is performed first, resulting in 10 - 10, which indeed equals 0.
8
Which operator is used for equality comparison in C?
Discuss
Answer & Solution
Answer: Option A
Solution:
In C, the == operator is used for equality comparison. It checks if the two operands are equal and returns true if they are, otherwise, it returns false.

Option B (=) is incorrect as it is the assignment operator, used to assign values to variables, not for equality comparison.
Option C (!=) is incorrect as it is the "not equal to" operator, used to check if two values are not equal.
Option D (<>) is not a valid equality comparison operator in C.
9
What does the sizeof operator return in C?
Discuss
Answer & Solution
Answer: Option B
Solution:
In C, the sizeof operator returns the size in bytes of the data type or variable provided as its operand. It is often used to determine the amount of memory occupied by a variable or data type.

Option A (Size of an array) is incorrect because sizeof returns the size of the data type or variable, not specifically for arrays.
Option C (Size of a pointer) is partially correct; sizeof can be used to determine the size of a pointer data type or a variable, but it is not limited to just pointers.
Option D (Size of a function) is incorrect because sizeof does not apply to functions in C.
10
What is the result of the expression (6 - 2) * (1 + 2) 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 (6 - 2) is evaluated first, resulting in 4, and (1 + 2) is evaluated as 3. Then, these results are multiplied: 4 * 3, which equals 12