Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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



main() { int i; printf("%d",((i=1)*i-- - --i*(i=-3)*i++ + ++i)); } ans is 2..

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

main() { int i; printf("%d",((i=1)*i-- - --i*(i=-3)*i++ + ++i)); } ans is 2..

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

main() { int i; printf("%d",((i=1)*i-- - --i*(i=-3)*i++ + ++i)); } ans is 2..

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

Post New Answer

More C Interview Questions

What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

0 Answers   Aspire, Infogain,


why we wont use '&' sing in aceesing the string using scanf

0 Answers   HCL,


What are the advantages of using new operator as compared to the function malloc ()?

0 Answers   NIIT,


There are N egg baskets and the number of eggs in each basket is a known quantity. Two players take turns to remove these eggs from the baskets. On each turn, a player must remove at least one egg, and may remove any number of eggs provided they all belong to the same basket. The player picking the last egg(s) wins the game. If you are allowed to decide who is going to start first, what mathematical function would you use to decide so that you end up on the winning side? Upload a C program to demonstrate the behaviour of the game.

2 Answers  


Do you have any idea how to compare array with pointer in c?

0 Answers  


Explain what are reserved words?

0 Answers  


which operator having lowest precedence?? a.)+ b.)++ c.)= d.)%

4 Answers  


How is pointer initialized in c?

0 Answers  


What does dm mean sexually?

0 Answers  


Compare interpreters and compilers.

0 Answers  


struct screen_pos{ int row, col } ;move_right(cursor)struct screen_pos *cursor;{ cursor.col++; } /* This statementhas a syntax error */What is the correct statement a) cursor.col = cursor.col + 1; b) col.cursor++; c) *cursor.col++; d) pointer

0 Answers  


What is difference between Structure and Unions?

0 Answers   TISL,


Categories