edited by
404 views
0 votes
0 votes

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);
    printf("%d\n",a);
    return 0;
}
  1. 14
  2. 36
  3. 18
  4. 20
edited by

1 Answer

2 votes
2 votes
As it is given (x*x) : The result will be b+2*b+2 which means: 4+2*4+2 = 14

Had it be ((x)*(x)): The answer would have been ((b+2)*(b+2)) = 36

Related questions

0 votes
0 votes
1 answer
1
kallu singh asked Dec 14, 2017
373 views
0 votes
0 votes
1 answer
2
iarnav asked Jan 2, 2017
398 views
What does this following expression means -*(*(* a[N])())()Please tell the detailed and simplified version to solve this. I only know mere basics of DS and programming, ...
0 votes
0 votes
1 answer
4
radha gogia asked Sep 27, 2015
380 views
I am geting confused with the term maximum of p sons , otherwise I was applying handshaking lemma but this maximum word is where I am getting stucked , so plz clarify thi...