#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 |
/*what is the output for the code*/ void main() { int r; r=printf("naveen"); r=printf(); printf("%d",r); getch(); }
Can a function argument have default value?
What is strcpy() function?
What is the difference between NULL and NUL?
#define MAX(x,y) (x) > (y) ? (x) : (y) main() { int i = 10, j = 5, k = 0; k = MAX(i++, ++j); printf("%d %d %d", i,j,k); } what will the values of i , j and k? }
14 Answers CDAC, GATE, NDS, TCS,
#include<stdio.h> #include<conio.h> void main() { char ch='\356'; printf("%d",ch); } o/p=-18 why?plz.explain
What is the correct code to have following output in c using nested for loop?
What happens if you free a pointer twice?
What is hashing in c?
main() { int i; printf("%d",scanf"%d",&i))//if the input is 12 24 34 then wat will be the output }
print the palindrome numbers in between 0 to n
if a person is buying coconuts of Rs10,and then sell that coconuts of Rs9,with the loss of one rupee.After that the person became a millaniore.how?