what is the difference between i++ and ++i?

Answers were Sorted based on User's Feedback



what is the difference between i++ and ++i? ..

Answer / moonlight

++i is pre increment and i++ is post increment. It is useful
in any codition.in pre increment it increases value of i
first then check it's value and in post increment it first
check it's value then increment.

Is This Answer Correct ?    29 Yes 1 No

what is the difference between i++ and ++i? ..

Answer / pedda

i++ and ++i mean the same thing but they have differently
i++ define post increment that means when the function
is completely after that the value is increment
Example:
i=4 find d=i++ + i; d=9 because i++
initially the value is 4 so 4+4=8 after tha the value d is
increment so finally d value is 9
++i define pre increment that means when the function
is starting increment
Example:
i=4 find d=++i +i; d=9 ++i value is increment
starting so ++i value is 5 so d value is 9

Is This Answer Correct ?    2 Yes 0 No

what is the difference between i++ and ++i? ..

Answer / geetha

i++ and ++i mean the same thing when they form statements
independently,they behave differently.
for example:
i=5;
d=++i;
in this case the value is i,d =6.bcoz first increment and
next assign the value
i=5;
d=i++;
in this case the value of d=5 and i=6.bcoz first assign the
value next increment and it will be change the value i=6.

Is This Answer Correct ?    2 Yes 1 No

what is the difference between i++ and ++i? ..

Answer / anika

in i++ first there is display and then the value in the memory
gets increased by 1.in ++i first value is increased by 1 then
display is there

Is This Answer Correct ?    3 Yes 3 No

what is the difference between i++ and ++i? ..

Answer / vinay

if they are used stand alone they are same ....

both increment the value of operand by 1

if they used in an expression then they will perform same
as mentioned in above answers...

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C Interview Questions

write a program which the o/p should b in such a way that s triangle if I/p is 3,a Square/rectangle if I/P=4,a pentagon if I/P=5 and so on...forget about the I/P which is less than 3

0 Answers   ADP,


write a function which accept two numbers from main() and interchange them using pointers?

3 Answers  


i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none

0 Answers  


how to exchnage bits in a byte b7<-->b0 b6<-->b1 b5<-->b2 b4<-->b3 please mail me the code if any one know to rajeshmb4u@gmail.com

3 Answers   Honeywell, Huawei,


Why is c so important?

0 Answers  






Why do we need arrays in c?

0 Answers  


What is 'bus error'?

0 Answers  


What is meant by int main ()?

0 Answers  


What does the format %10.2 mean when included in a printf statement?

0 Answers  


int i=0,j; j=++i + ++i ++i; printf(" %d",j);

2 Answers   ME,


Write a c program to print the sizes and ranges of different data types in c?

1 Answers  


What are structure members?

0 Answers  


Categories