recategorized by
8,027 views

9 Answers

Best answer
17 votes
17 votes

The macro function SQR(x)(x*x) calculate the square of the given number 'x'. (Eg: 102)

Step 1int a, b=4; Here the variable a, b are declared as an integer type and the variable b is initialized to 4.

Step 2a = SQR(b+2); becomes,

=> a = b+2 * b+2; Here SQR(x) is replaced by macro to x*x .

=> a = 4+2 * 4+2;

=> a = 4 + 8 + 2;

=>a=14
selected by
12 votes
12 votes

Ans will be 14

#include <stdio.h>
#define SQR(x) (x*x)
 
int main(void) {
	int a;
	int b=4;
	a=SQR(b+2); // here it will compute (b+2*b+2)=4+2*4+2=4+8+2=14
	printf("%d",a);
	return 0;
}
3 votes
3 votes
It will print 14.

Because due to macro expression will get converted into

b + 2 * b + 2 === > 4 + 2 * 4 + 2 ==> 14
3 votes
3 votes
preprocessor expands, a = SQR(b+2); as

a= x + 2 * x + 2

a= 4 + 8 + 2

a = 14

option A would be the answer
Answer:

Related questions

2 votes
2 votes
4 answers
1
jenny101 asked Jun 25, 2016
4,886 views
The following three 'C' language statements is equivalent to which single statement?y=y+1; z=x+y; x=x+1z = x + y + 2;z = (x++) + (++y);z = (x++) + (y++);z = (x++) + (++y)...
6 votes
6 votes
3 answers
2
Sourabh Kumar asked Jun 22, 2016
5,553 views
How many lines of output does the following C code produce?#include<stdio.h float i=2.0; float j=1.0; float sum = 0.0; main() { while (i/j 0.001) { j+=j; sum=sum+(i/j); ...
8 votes
8 votes
7 answers
3