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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of #include in c?

580


What is #include cctype?

580


Explain can the sizeof operator be used to tell the size of an array passed to a function?

597


Do you know the use of 'auto' keyword?

662


What is the return type of sizeof?

596






Explain how can I avoid the abort, retry, fail messages?

591


Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?

603


What is difference between union All statement and Union?

628


How is a structure member accessed?

585


Is swift based on c?

640


What is wrong with this program statement? void = 10;

822


What are the 5 data types?

602


How does struct work in c?

611


write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays

1786


What is echo in c programming?

559