Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int f1(int x, int y){
- return x+y;
- }
- int f2(int x){
- return ++x;
- }
- int f3(int x){
- return x++; /* postfix version, return value will not be incremented,
- use the prefix version to increment before returning, ++x
- example f2()
- */
- }
- int f4(int x){
- x++;
- int y = x;
- return y;
- }
- int main (int argc, char **argv){
- int a,b;
- a = 1;
- b = 2;
- printf("f1: %d\n",f1(a,b));
- printf("f2: %d\n",f2(a));
- printf("f3: %d\n",f3(a));
- printf("f4: %d\n",f4(a));
- return 0;
- }
- /*
- output:
- f1: 3
- f2: 2
- f3: 1
- f4: 2
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement