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

a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list

0 Answers  


please send me the code for multiplying sparse matrix using c

0 Answers  


What is conio h in c?

0 Answers  


main() { printf("hello%d",print("QUARK test?")); }

5 Answers  


What functions are used in dynamic memory allocation in c?

0 Answers  






What is the advantage of a random access file?

0 Answers  


write the function int countchtr(char string[],int ch);which returns the number of timesthe character ch appears in the string. for example the call countchtr("she lives in Newyork",'e') would return 3.

6 Answers  


How can I get random integers in a certain range?

0 Answers  


1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. 2) the Event Manager has to send participants to the stage to perform in the order in which they registered. Write a program that will help the Event Manager know who to call to the stage to perform. The Logic should be in Data Structures

0 Answers   KPIT,


struct ptr { int a; char b; int *p; }abc; what is d sizeof structure without using "sizeof" operator??

9 Answers   Verifone,


What is data type long in c?

0 Answers  


what is bitwise operator?

1 Answers   IBM,


Categories