main()
{ int i;
printf("%d",((i=1)*i-- - --i*(i=-3)*i++ + ++i));
}
ans is 24 bt how?pls tell smbody............
Answers were Sorted based on User's Feedback
Answer / gorgeousgirl
Answer: 34
confirm the answer with http://codepad.org/PudiZIaS
Explanation:
by order of precedence, parenthesis hav highest priority
so
(i=1)*i-- - --i*(i=-3)*i++ + ++i
i=1 i=-3
now, i=-3
after assignment operations the expr becomes,
>(i)*i-- - --i*(i)*i++ + ++i
next higher priority is for auto-in/decrement
omitting post in/decrement(as they hav effect only after
this line of code), we get,
> i*i - --i*i*i + ++i
the associativity for printf statement is from right to left
so ++i is executed first before --i where i=-3
> i*i - --i*i*i + -2
now i=-2
> i*i - -3*i*i + -2
now i =-3
next precedence is for multiplication
> -3*-3
-
-3*-3*-3
+
-2
> 9 - -27 + -2
> 9 + 27 -2
> 9 + 25
> 34
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / sureshb
value is 26 and i value is -2.
Intiallay i=1 is assiged.
((i=1)*i--) 1st expression = 1 postfix decrement evaluates at the end.
now i=1
--i => 0. 2nd expression
i=-3 assigned new value 3rd expression.
-3*-3 => 9 *(-3) => -27
++ post increment done at the end
-(-27) = 27.
1+ 27 =>28
now i is -3.
++i => -2;
28-2= 26.
i=-2;
post increment and decrement happens. finaaly i = -2.
| Is This Answer Correct ? | 5 Yes | 3 No |
Answer / rama krishna sidhartha
Actually answer is not 24 it is -7567. When i executed this
in the turbo c compiler i got the answer like that.
| Is This Answer Correct ? | 0 Yes | 2 No |
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?
A MobileNumber is a VIP number if it satisfy the following conditions. The operator should be Vodafone. Atleast one 0 (Zero) should be exist in mobile number. The number should not end with 8. The single digit sum of all the digits in the number should be equal to 9. For example if the number is 9876543210, the sum is 9+8+7+...+1+0 = 45. Sum of 4+5 = 9. Write a method: private boolean isVIPMobileNumber(String mobileNum, String operator) mobileNum phone number operator mobile operator as bsnl, Vodafone
Write a c program to read a positive number and display it in words.? ex: 123=one two three help me....
Would you rather wait for the results of a quicksort, a linear search, or a bubble sort on a 200000 element array? 1) Quicksort 2) Linear Search 3) Bubble Sort
In which header file is the null macro defined?
What are the different categories of functions in c?
How many levels deep can include files be nested?
Which is an example of a structural homology?
b) 4 c) 6 d) 7 32. Any C program a) must contain at least one function b) need not contain ant function c) needs input data d) none of the above 33. Using goto inside for loop is equivalent to using a) continue b) break c) return d)none of the above 34. The program fragment int a=5, b=2; printf(“%d”,a+++++b); a) prints 7 b)prints 8 c) prints 9 d)none of the above 35. printf(“ab” , “cd”,”ef”); prints a) ab abcdef c) abcdef, followed by garbage value d) none of the above 36. Consider the following program segment. i=6720; j=4; while((i%j)==0) { i=i/j; j=j+1; } On termination j will have the value a) 4 b) 8 c) 9 d) 6720
What does #pragma once mean?
What is the use of linkage in c language?
How is a macro different from a function?