Wednesday, April 29, 2009

What is the difference between a++ and ++a?

The difference between a++ and ++a, is that when we use a++ in a program and then the effect would be on the next statement while the ++a, effect is that on the current line not on the next statement. Example code:


Output:


Code:

#include<……>

#include<……>

int main()

{

int c=1;

c=5;

printf("%d\n",c);

printf("%d\n",c++);

printf("%d\n\n",c);

c=10;

printf("%d\n",c);

printf("%d\n",++c);

printf("%d",c);

getch();

}

2 comments:

Anonymous said...

john i add ni na blog beh gaddgetz.blogspot.com....salamat

Anonymous said...

人生中最好的禮物就是屬於自己的一部份