Discuss about structures and functions With example program

A structure is a bit more complicated than a single value, so it is not surprising that ancient C implementations do not allow a structure to be used as an argument for a function.it can be passed as a function argument to a function that accepts that particular type.    

#include <stdio.h>

#define FUNDLEN 50
struct funds {
    char   bank[FUNDLEN];
    double bankfund;
    char   save[FUNDLEN];
    double savefund;
};
double sum(double, double);
int main(void)
{

    struct funds stan = {
        "Garlic-Melon Bank",
        3024.72,
        "Lucky's Savings and Loan",
        9237.11
    };

    printf("Stan has a total of $%.2f.\n",
           sum(stan.bankfund, stan.savefund) );

    return 0;

}                          



0 Comment "Discuss about structures and functions With example program"

Post a Comment