#include <stdio.h>
#define sqr(x) (x*x)
int main()
{
int x=2;
printf("value of x=%d",sqr(x+1));
}

What is the value of x?

Answers were Sorted based on User's Feedback



#include <stdio.h> #define sqr(x) (x*x) int main() { int x=2; printf("value of x..

Answer / divakar

ouput :value of x=5
bcoz sqr(x+1)=(x+1*x+1) if u substitute x=2 u will get 5
since '*' is having more priority than '+'

at the of prog if u add prinf("%d",x); u will get 2
bcoz x value is not changed

Is This Answer Correct ?    32 Yes 4 No

#include <stdio.h> #define sqr(x) (x*x) int main() { int x=2; printf("value of x..

Answer / vijaya

5

Is This Answer Correct ?    34 Yes 12 No

#include <stdio.h> #define sqr(x) (x*x) int main() { int x=2; printf("value of x..

Answer / gg

Ans : 5

I agree with Divakar ans & similar answers.

sqr(x+1)=x+1*x+1=2+1*2+1=5, but not 2*2+1

Is This Answer Correct ?    17 Yes 0 No

#include <stdio.h> #define sqr(x) (x*x) int main() { int x=2; printf("value of x..

Answer / bhagya

absolutely 5

Is This Answer Correct ?    16 Yes 0 No

#include <stdio.h> #define sqr(x) (x*x) int main() { int x=2; printf("value of x..

Answer / guest

i tried in pc the ans is 5

Is This Answer Correct ?    15 Yes 3 No

#include <stdio.h> #define sqr(x) (x*x) int main() { int x=2; printf("value of x..

Answer / ndarvind

5
Bcz 2+1*2+1=5

Is This Answer Correct ?    14 Yes 2 No

#include <stdio.h> #define sqr(x) (x*x) int main() { int x=2; printf("value of x..

Answer / azeem khan

Answer is 5

Is This Answer Correct ?    19 Yes 9 No

#include <stdio.h> #define sqr(x) (x*x) int main() { int x=2; printf("value of x..

Answer / pravin

sqrt(x+1)(x+1*x+1)
as x=2;result will be 2+1*2+1=5;
thank u

Is This Answer Correct ?    6 Yes 1 No

#include <stdio.h> #define sqr(x) (x*x) int main() { int x=2; printf("value of x..

Answer / jugal

Sorry guys,
my bad,
i thought it was
#define sqr(x) ((x)*(x))

the output wud be 5
but still the value of will be 2 only

Is This Answer Correct ?    2 Yes 0 No

#include <stdio.h> #define sqr(x) (x*x) int main() { int x=2; printf("value of x..

Answer / fazlur

Macro will blindly substitutes, it doesn't calculate. So
remember whenever you encounter the macro, you first
substitute the value then calculate later. Ofcourse the
answer would be 5 in this case.

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C Interview Questions

What is the difference between volatile and const volatile?

0 Answers  


What is the difference between functions abs() and fabs()?

0 Answers  


Is c pass by value or reference?

0 Answers  


Where in memory are my variables stored?

0 Answers  


1. Write the function int countchtr(char string[ ], int ch); which returns the number of times the character ch appears in the string. Example, the call countchtr(“She lives in NEWYORK”, ‘e’) would return 3.

4 Answers  






what is difference between declaring the pointer as int and char in c language?

3 Answers  


1.Why do you call C is middle level language? 2.Why do you call C is userfriendly language.

2 Answers  


What is the difference between arrays and pointers?

0 Answers  


What is New modifiers?

0 Answers   NA,


print the palindrome numbers in between 0 to n

1 Answers  


multiple of 9 without useing +,* oprator

3 Answers  


char S; char S[6]= " HELLO"; printf("%s ",S[6]); output of the above program ? (0, ASCII 0, I,unpredictable)

7 Answers   Mascot,


Categories