#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

inline function is there in c language?

4 Answers  


What is the difference between class and object in c?

0 Answers  


1. Write a C program to count the number of occurrence of a specific word in the given strings. (for e.g. Find how many times the word “live” comes in the sentence “Dream as if you’ll live forever, live as if you’ll die today ”)

12 Answers   Eskom, TCS,


how to implement stack operation using singly linked list

2 Answers  


Why c is a procedural language?

0 Answers  






What is malloc and calloc?

0 Answers  


What is console in c language?

0 Answers  


Can you mix old-style and new-style function syntax?

0 Answers  


What is the meaning When we write "#include" what is # and what does include does there???

22 Answers   HCL, Wipro,


What is ## preprocessor operator in c?

0 Answers  


can we store values and addresses in the same array? explain

3 Answers   TCS,


Hai friends im a i year student. i want to develop my knowledge in the field of TSR in c. How I'm Improve ?

2 Answers  


Categories