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...


void main()
{
int i=5;
printf("%d",i++ + ++i);
}

Answers were Sorted based on User's Feedback



void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / ishrat ali

the calculate of any expression can be done from left to
right,so first i++ compute it means 1st use then increment 5
is used in place of i++ and after using the value of i
increment that is 6.
after that ++i is used that is 1st increment then use in the
expression so now ++i is replaced by 7;
finally 6+7=12 (ans)

Is This Answer Correct ?    1 Yes 0 No

void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / veeraselvi.g

ans:12
explan:i++ means increment for 6 bt print will be 5;
other i++ for 6 to increment for 7
so ans is 12

Is This Answer Correct ?    0 Yes 0 No

void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / gajendra

1

Is This Answer Correct ?    1 Yes 1 No

void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / poseidon

I might agree with ANS #1 because side effects are
involved..The expected answer might not be getting always
although in case of printf(), the arguments are evaluated
from RTL. For example consider the case

int i=10;
printf("%d %d %d %d",i++,--i,i--,--i);
Try some variations of these and and find out whether you
are able to get correctly or not..
In case the result depends on the compiler,for
verification,I will add what my compiler gave me
ANS:7 8 9 8
If anyone find out,pls reply.. Keen to know..

Is This Answer Correct ?    0 Yes 0 No

void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / buvaneswari

as already told,the precedence wil be from right to left..
so i++ the value wil be still 5 and incremented value wil be stored in memory..
and next ++i now the value of i=5 not considering the memory value...so ++i =6...now the new value of i is 6.this wil be replaced the value 5 in the memory
u can see the expression as i+i in default or consider to be
i=i++ and i=++i....so i+i(ie)6+6=12....

Is This Answer Correct ?    0 Yes 1 No

void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / pnkj rajput@kiit,bbsr

Ans. is

12

because

(first check) i++ (no change in the value of 'i' so i=5)

(second check) ++i ('i' increase by 1 so, i=6)

Now, in this the value of 'i' is 6

so, 6 + 6 = 12

Is This Answer Correct ?    0 Yes 1 No

void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / kaushik

13

i=i++--->6

++6=7

7+6=13

Is This Answer Correct ?    0 Yes 1 No

void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / surenda pal singh chouhan

Output Cannot be predicted exactly.

Explanation:
Side effects are involved in the evaluation of i

Is This Answer Correct ?    13 Yes 15 No

void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / guest

same as the pervious question....

11 ans

Is This Answer Correct ?    11 Yes 22 No

void main() { int i=5; printf("%d",i++ + ++i); }..

Answer / jignesh patel

i++=5
++i=6

so i++ + ++i = 5+6=11

Is This Answer Correct ?    6 Yes 26 No

Post New Answer

More C Interview Questions

what is answer for perfect number????????????????

1 Answers  


#&#8206;include&#8236;<stdio.h> void main() { int i; for(i=5;0;i++) { printf("%d",i); } }

2 Answers   Facebook,


Explain the concept and use of type void.

0 Answers  


Can you write the algorithm for Queue?

0 Answers   College School Exams Tests, TCS,


in a town the percentage of men is 52 the percentage of total literacy is 48 if total percentage of literate men is 35 of the total population write a program to find the total no of the literate men and women if the population of the town is 80000

3 Answers  


What is a null string in c?

0 Answers  


How can you tell whether two strings are the same?

0 Answers  


write a program to generate address labels using structures?

0 Answers   SJC,


What is the symbol indicated the c-preprocessor?

0 Answers  


What does != Mean in c?

0 Answers  


How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?

0 Answers  


How can I read a binary data file properly?

0 Answers  


Categories