What is the output of the following program?#include <stdio.h>
#define SQR(x) (x*x)
int main() {
int a, b = 3;
a = SQR(b+2);
printf("%d", a);
return 0;
}
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: B. 11
Explanation
Macro expansion gives (b+2*b+2) = 3 + 6 + 2 = 11, because the argument is not parenthesised.More Programming Languages and Computer Graphics questions
- Consider the three points P1(1, 2, 0), P2(3, 6, 20) and P3(2, 4, 6) and a viewpoint C(0, 0, −10). Choose the correct options. (A) P1 obscur…
- Which of the statements are CORRECT? (A) Constructors are invoked automatically when objects are created. (B) Constructors do not have retu…
- Match List I with List IIList I List II (a) Bresenham (I) Hidden surface removal (b) Cohen-Sutherland algorithm (II) Line drawing (c) Suthe…
- Consider the following code segment:int arr[] = {0,1,2,3,4}; int i = 1, *ptr; ptr = arr + 2; Arrange the following printf statements in inc…
- Statement (I): A friend function and the member functions of a friend class can directly access private and protected data. Statement (II):…
- Match List I with List IIList I List II A. Bezier curves I. 3-D objects that have translational/rotational symmetry B. B-Splines II. Fracta…