/* * Program to: * (a) add two numbers * (b) add marks in various subjects to obtain total */ #include /** * struct rec - stores marks obtained in various subjects * @icp: marks obtained in ICP * @dfs: marks obtained in DFS * @total: total marks */ struct rec { int icp; int dfs; int total; }; int add_num(int *, int *); void add_marks(struct rec *); int main() { int b; int c; struct rec b2020020; b=100; c=200; b2020020.icp=60; /* marks in ICP */ b2020020.dfs=70; /* marks in DFS */ printf("add_num: %d + %d = %d\n\n", b, c, add_num(&b, &c)); add_marks(&b2020020); printf("rec.total = %d\n\n", b2020020.total); return 0; } /** * add_num - returns sum of two integers obtained through pointers * @x: pointer to first number * @y: pointer to second number * * We assume that the sum of the two integers given by the user is a valid * and correct integer. **/ int add_num(int *x, int *y) { return ( *x + *y ); } /** * add_marks - finds rec.total * @record: &struct rec * * We take the student record and add the marks to total **/ void add_marks(struct rec *record) { record->total = record->icp + record->dfs; }