LIVE Course for free

Rated by 1 million+ students
Get app now
0 votes
in Information Technology by (46.1k points)
closed by

What is the output of the following C program?

#include <stdio.h>

#define SQR(x) (x*x)

int main ( )


int a;

int b = 4;

a = SQR(b + 2);


return 0;


1. 14
2. 36
3. 18
4. 20

1 Answer

0 votes
by (30.0k points)
selected by
Best answer
Correct Answer - Option 1 : 14

The correct answer is "option 1".


The #define is the preprocessor directive used to define micro substitution or constant.

By #define directive compiler substitutetoken for each occurrence of defined constant or identifier in the source file.

Only when the identifier forms a token, it gets replaced.


The given code will perform the calculation as:

Value of b = 4

SQR(x) → (x*x)

SQR(b+2) →


(4+2*4+2) → 14

Hence, the value of a is 14.

Never consider ( a * a ) as (a) * (a).

Eg. If a = b+2 then, (b+2 * b+2) is correct & (b+2)*(b+2) is wrong.

Related questions

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.