Advertisement
thenewboston

C Programming Tutorial - 56 - Passing Arguments to Functions

Aug 23rd, 2014
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void convertToDollars(float euro);
  5.  
  6. int main()
  7. {
  8.     float euroPrice1 = 1.00;
  9.     float euroPrice2 = 5.00;
  10.  
  11.     convertToDollars(euroPrice1);
  12.     convertToDollars(euroPrice2);
  13.  
  14.     return 0;
  15. }
  16.  
  17. //sometimes your functions need extra information, like when making calculations
  18. //when you pass in a variable, you can use it in another function
  19. void convertToDollars(float euro){
  20.     float usd = euro * 1.37;
  21.     printf("%.2f Euros - %.2f USD\n", euro, usd);
  22.     return;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement