Question:

What is the output of the following C program? #define sqr(x) (x*x) main() { int a, b = 13; a = sqr(b + 12); printf("%d", a); }

Show Hint

Be cautious when using macros, as they perform direct textual substitution, which might lead to unexpected results.
Updated On: May 3, 2025
  • 625
  • 181
  • 225
  • 192
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

The macro \( \text{sqr}(x) \) is defined as \( (x \times x) \). In the expression \( \text{sqr}(b + 12) \), we get: \[ \text{sqr}(b + 12) = (b + 12) \times (b + 12) = (13 + 12) \times (13 + 12) = 25 \times 25 = 625. \]
Thus, the output of the program is \( 181 \) after evaluating the result from the macro correctly.
Was this answer helpful?
0
0

Top Questions on Programming in C

View More Questions