#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

What is time null in c?

0 Answers  


Explain continue keyword in c

0 Answers  


Read two numbers from keyboard and find maximum of them?

1 Answers  


A C E G H +B D F A I ------------ E F G H D

1 Answers   Infosys,


When a c file is executed there are many files that are automatically opened what are they files?

0 Answers  






What is the purpose of Scanf Print, getchar, putchar, function?

3 Answers  


How important is structure in life?

0 Answers  


HOW TO ANSWER IF ASKED " WHAT KIND OF A PERSON ARE YOU?" I NEED AN ANSWER THAT IMPRESS THE INTERVIEWER

4 Answers  


What are different types of pointers?

0 Answers  


You are given a string which contains some special characters. You also have set of special characters. You are given other string (call it as pattern string). Your job is to write a program to replace each special characters in given string by pattern string. You are not allowed to create new resulting string. You need to allocate some new memory to given existing string but constraint is you can only allocate memory one time. Allocate memory exactly what you need not more not less.

2 Answers   Microsoft,


what is op? for(c=0;c=1000;c++) printf("%c",c);

21 Answers   Trigent,


What is 'makefile' in C langauage? How it be useful? How to write a makefile to a particular program?

2 Answers  


Categories