#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

print out of string in this format; 1. "rajesh" 2. \n 3. %d

5 Answers   mpower,


what is the role you expect in software industry?

0 Answers   HCL,


define switch statement?

6 Answers   CTS,


Can you write the algorithm for Queue?

0 Answers   College School Exams Tests, TCS,


Why is struct padding needed?

0 Answers  






What is a spanning Tree?

1 Answers   TCS,


What is the difference between CV and Resume ?

2 Answers  


What is string length in c?

0 Answers  


WHAT WILL BE OUTPUT OF BELOW CODE . . AND PLEASE EXPLAIN HOW IT COME .. #include<stdio.h> #include<conio.h> void main() { int k=20; printf("%d%d%d%d",k,k++,++k,k); getch(); }

25 Answers  


how to find turn around time in operating system?

3 Answers  


write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.

0 Answers   Subex,


totally how much header files r in c language

8 Answers   TCS,


Categories