Guest User

Untitled

a guest
Apr 21st, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. /*Both x and y are required to pass information to and from the function but that's 2
  2. variables not just one (like you do when you write a program w/ no
  3. functions at all - one that is entriely in main w/ just basic routines like printf
  4. and scanf). This is a difference and a big one. What is going on here between these
  5. 'two' variables? They don't seem to be accomplishing anything more than the single
  6. variable "x" in what it does between lines 15 and 16 - why two of them to accomplish
  7. the same thing then? (just passing data).*/
  8.  
  9. #include <stdio.h>
  10.  
  11. int main (void)
  12. {
  13. int x;
  14.  
  15. printf("Enter a value: \n");
  16. scanf("%d", &x);
  17.  
  18. printf("%d\n", func());
  19. }
  20.  
  21. int func(int y) {
  22. int total;
  23.  
  24. total = x*2;
  25. return total;
  26. }
Add Comment
Please, Sign In to add comment