#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 / jugal

The OUTPUT of the program wud be
"value of x=9"

NOTE:
#define sqr(x) (x*x) and
#define sqr(x) x*x
are two very different things
what Divakar and all are saying is referring to the 2nd
one, where as in this case the 1st one is given


Coming to the actual question
The value of x will remain 2, since its value is not being
changed anywhere in the program, its just being passed to a
macro, but NOT modified there either.
Try adding a line at the end of the program
printf("x=%d",x);

Is This Answer Correct ?    1 Yes 1 No

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

Answer / poorna

Warning: Function Should have return value........

Is This Answer Correct ?    4 Yes 5 No

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

Answer / guest

the x itself is 2 and the print out is 9

Is This Answer Correct ?    14 Yes 16 No

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

Answer / c harlee jain

Value of x will be 2

Is This Answer Correct ?    2 Yes 4 No

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

Answer / grbr

9

Is This Answer Correct ?    3 Yes 8 No

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

Answer / anil

27

Is This Answer Correct ?    3 Yes 16 No

Post New Answer

More C Interview Questions

Eight queens puzzle

0 Answers  


What are the types of type specifiers?

0 Answers  


What are loops c?

0 Answers  


Implement a function that returns the 5th element from the end in a singly linked list of integers in one pass.

11 Answers   Microsoft,


What is a macro in c preprocessor?

0 Answers  






Was 2000 a leap year?

0 Answers  


What is typedf?

0 Answers  


create a C program that displays one z,two y's,three x's until twenty six A's. plzz answer i need it tomorrow.

4 Answers  


how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?

0 Answers   Gopaljee, TCS,


Tell me what are bitwise shift operators?

0 Answers  


How we add our function in liabrary as liabrary function. Exp. we want use our int factorical(int); function as int pow(int,int); function working in math header file.

1 Answers  


How do I determine whether a character is numeric, alphabetic, and so on?

0 Answers  


Categories