funds3.c 568 B

12345678910111213141516171819202122232425262728293031
  1. /* funds3.c -- passing a structure */
  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(struct funds moolah); /* argument is a structure */
  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", sum(stan));
  20. return 0;
  21. }
  22. double sum(struct funds moolah)
  23. {
  24. return(moolah.bankfund + moolah.savefund);
  25. }