funds1.c 583 B

1234567891011121314151617181920212223242526272829303132
  1. /* funds1.c -- passing structure members as arguments */
  2. #include <stdio.h>
  3. #define FUNDLEN 50
  4. struct funds {
  5. char bank[FUNDLEN];
  6. double bankfund;
  7. char save[FUNDLEN];
  8. double savefund;
  9. };
  10. double sum(double, double);
  11. int main(void)
  12. {
  13. struct funds stan = {
  14. "Garlic-Melon Bank",
  15. 4032.27,
  16. "Lucky's Savings and Loan",
  17. 8543.94
  18. };
  19. printf("Stan has a total of $%.2f.\n",
  20. sum(stan.bankfund, stan.savefund) );
  21. return 0;
  22. }
  23. /* adds two double numbers */
  24. double sum(double x, double y)
  25. {
  26. return(x + y);
  27. }