Advertisement
alaestor

return example C

Feb 25th, 2021 (edited)
1,026
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. // define a new function named "addThree" which takes an int argument
  2. int addThree(int input)
  3. {
  4.     // return the result of the expression "input+3"
  5.     return input+3;
  6. }
  7.  
  8. // define the standard entrypoint for a C program, "main()"
  9. int main()
  10. {
  11.     // initialize variable n
  12.     int n = 0;
  13.  
  14.     // call addThree the parameter literal integer "2"
  15.     // store the returned value in n
  16.     n = addThree(2);
  17.  
  18.     // add 5 to n and store the result in n
  19.     n = n + 5;
  20.  
  21.     // exit program by returning from main
  22.     // 0 is the standard "OK" program exit code
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement