#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
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 |
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 |
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 |
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 |
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 |
When the macros gets expanded?
What is the use of f in c?
difference between memcpy and strcpy
Can the “if” function be used in comparing strings?
write a program that will read the temperature in Celsius and convert that into Fahrenheit.
void main(int argc,char *argv[],char *env[]) { int i; for(i=1;i<argc;i++) printf("%s",env[i]); }
f1() { f(3);} f(int t) { switch(t); { case 2: c=3; case 3: c=4; case 4: c=5; case 5: c=6; default: c=0;} value of c?
What is the use of #include in c?
sir, i cannot find the way how to write aprogram by using array on queue
the portion of a computer program within which the definition of the variable remains unchanged a) mode b) module c) scope d) none
what is difference between getchar,putchar functions and printf and scanf function? does putchar show output only when input given to it
How do you construct an increment statement or decrement statement in C?