SHARE
TWEET

Untitled

a guest Nov 19th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  //function prototypes
  3. int addNumbers(int, int);
  4. void addNumbersPointers(int *, int *, int *);
  5. int main(void) {
  6.   int var1 = 2;
  7.   int var2 = 4;
  8.   int var3 = 0;
  9.   var3 = addNumbers(var1, var2);
  10.   printf("The answer is: %2d\n", var3);
  11.   //reset variables
  12.   var1 = 2;
  13.   var2 = 4;
  14.   var3 = 0;
  15.   addNumbersPointers( &var1, &var2, &var3);
  16.   printf("The answer is: %2d\n", var3);
  17.  
  18.   //reset variables
  19.   var1 = 2;
  20.   var2 = 4;
  21.   var3 = 0;
  22.  
  23.   return 0;
  24. } //end main
  25. int addNumbers(int x, int y) {
  26.   return x + y;
  27. }
  28. void addNumbersPointers(int *x, int *y, int *z) {
  29.   *z = *x + *y;
  30.   return;
  31. } //end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top