main()
{
int i = -3,j=2,k=0,m;
m= ++i || ++j && ++k;
printf("%d%d%d",i,j,k,m);
}
Answers were Sorted based on User's Feedback
Answer / harend
results :
i=-2
j=2
k=0
m=1
First, the '&&' part is to be considered over '||'.
AS follow: m = ++i||++j&&++k (is given)
what ever be the result of (++j&&++k),the value of m =1
,since the new value i= -2 (i.e a non zero value so taken as
true or 1)
so,
1||(++j&&++k) will always be true, that is 1 . compiler
ignores ++j ,++k and only consider ++i.
thank you !
| Is This Answer Correct ? | 25 Yes | 6 No |
Answer / ep
After the execution of the m evaluation the variables can be:
i = -2
j = 2
k = 0
m = 1
All of of this is because compilers do NOT completely
evalute expressions if they can short cut the evaluation.
Anyway, this is very bad programming.
| Is This Answer Correct ? | 18 Yes | 10 No |
Answer / mayur dharmik
printf("%d%d%d",i,j,k,m);
it has only 3 %d.
So, it will print only 3 value.
| Is This Answer Correct ? | 9 Yes | 2 No |
Answer / mayur dharmik
output
-220
i.e,
i=-2, j=2, k=0.
it will print only 1st three value.
| Is This Answer Correct ? | 5 Yes | 2 No |
Answer / nidhi yadav
here logical && has higher priority than ||. so the block
(++j&&++k)will execute first and ans of this will be (3&&1=0)
since value increment first due to preincrement operator. now
the block(++i||0)will execute as (-2||0=1) since || opertor always gives true value except(0||0=0).
thus ans will be i=-2,j=3,k=1,m=1
| Is This Answer Correct ? | 2 Yes | 7 No |
Write a C program to get the desired output. 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 . . . 1 n..............n 1 Note: n is a positive integer entered by the user.
write a program to display the numbers in the following 4 4 3 3 2 2 1 1 0 1 1 2 2 3 3 4 4
What does d mean?
What is structure padding and packing in c?
When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd
difference between semaphores and mutex?
WAP to accept rollno,course name & marks of a student & display grade if total marks is above 200?
Why is %d used in c?
what is the height of tree if leaf node is at level 3. please explain
What is a macro in c preprocessor?
main() {int i=5; // line 1 i=(++i)/(i++); // line 2 printf("%d",i); // line 3 } output is 2 but if we replace line 2 and line 3 by printf("%d",i=(++i)/(i++)); then output is 1. Why?
Explain how do you override a defined macro?