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 |
Why is the code below functioning. According to me it MUST NOT.
program to find the magic square
Describe advantages and disadvantages of the various stock sorting algorithms
Explain output of printf("Hello World"-'A'+'B'); ?
Read N characters in to an array . Use functions to do all problems and pass the address of array to function. 1. Print only the alphabets . If in upper case print in lower case vice versa. 2. Enter alphanumeric characters and form 2 array alphaets and digits.Also print the count of each array. 3. Find the count of a certain character. 4. Print the positions where a certain character occured. 5. Print the characters between successive array elements. 6. Find the largest and smallest charcter. How many times it each one occured. 7. Enter a certain range. Print out the array elements which occured between these range. 8. Reverse a character array without using another array. 9. Reverse an array region. 10. Replace a the array elements with it next character . Use a after z. 11. Code the array element with certain character as first alphabet. 12. Duplicate all the vowels in a character array. What is the new count. 13. Delete the vowels in a character array. What is the new array count. 14. Print the count of all characters in the array. 15. Enter n alphabets and store a upto tht charcter in array.What is the array count? 16. Sort a character array. 17. Merge 2 character arrays largearray,smallarray. 18. Find the pair with largest number of characters in between. 19. Find the numerical value of a charcter array. 20. Store n numeral characters in an arrray. Insert another numeral character in a certain position. 21. Insert a character in a sorted array. 22. Merge 2 sorted arrays in sorted fashion. 23. Duplicate the least occuring character. 24. Write a menu driven program to circular right/left shift an array of n elements. 25. Is the character array palindrome? if not make it palindrome. 26. Concatenate the first n charaters to the end of the string. 27. Print all n group of chracters which are palindrome. 28. Concatneate the reverse of last n characters to the array.
Can we change the value of constant variable in c?
How many types of operator or there in c?
Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.
implement OR gate without using any bitwise operator.
Why do we use namespace feature?
If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above
who is the founder of c
19 Answers College School Exams Tests, HP,