what is the difference between i++ and ++i?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
What is const volatile variable in c?
Is the below things valid & where it will be stored in memory layout ? static const volatile int i; register struct { } ; static register;
2. Write a function called hms_to_secs() that takes three int values—for hours, minutes, and seconds—as arguments, and returns the equivalent time in seconds.. Create a program that exercises this function by repeatedly obtaining a time value in hours, minutes, and seconds from the user (format 12:59:59), calling the function, and displaying the value of seconds it returns.
Discuss the function of conditional operator, size of operator and comma operator with examples.
write a c program to print the values in words eg:- 143 written it has (one hundred and forty three)& 104, 114 are also written words
5 Answers Captronic, DELL, Google, IBM, Mithi, RCC, Wipro,
How to implement call back functions ?
What is difference between && and & in c?
Explain what is a static function?
main() { char p[] = "hello world!"; p = "vector"; printf("%s",p); }
2 Answers Vector, Vector India,
What is a char c?
which operator having highest precedence? a.)+ b.)++ c.)= d.)%
Program to find larger of the two numbers without using if-else,while,for,switch