TEZPUR 2025 Computer PYQ — Given , what will be the value of the integer after execution of … | Mathem Solvex | Mathem Solvex
Tip:A–D to answerE for explanationV for videoS to reveal answer
TEZPUR 2025 — Computer PYQ
TEZPUR | Computer | 2025
Given q=20,r=30,s=40, what will be the value of the integer X after execution of the C statement:
X=++q∗r/s;
Choose the correct answer:
A.
15.75
B.
16.75
C.
16
D.
15
(Correct Answer)
Correct Answer:
15
Explanation
To find the value of X, we must follow the rules of C operator precedence and associativity.
Pre-increment (++q): The ++ operator has higher precedence than multiplication and division. The pre-increment operator increases the value of q before it is used in the expression.
qnew=q+1=20+1=21
Expression Evaluation: The expression now becomes:
X=21∗30/40
Associativity: Multiplication (*) and division (/) have the same precedence and are evaluated from left to right.
First, perform the multiplication:
21∗30=630
Next, perform the division:
630/40=15.75
Integer Truncation: The variable X is declared as an integer. In C, when a floating-point value is assigned to an integer variable, the decimal portion is truncated (not rounded).
X=⌊15.75⌋=15
Explanation
To find the value of X, we must follow the rules of C operator precedence and associativity.
Pre-increment (++q): The ++ operator has higher precedence than multiplication and division. The pre-increment operator increases the value of q before it is used in the expression.
qnew=q+1=20+1=21
Expression Evaluation: The expression now becomes:
X=21∗30/40
Associativity: Multiplication (*) and division (/) have the same precedence and are evaluated from left to right.
First, perform the multiplication:
21∗30=630
Next, perform the division:
630/40=15.75
Integer Truncation: The variable X is declared as an integer. In C, when a floating-point value is assigned to an integer variable, the decimal portion is truncated (not rounded).