- #1
cs23
- 66
- 0
I'm trying to point to the data in struct ele709_record john_doe into the total_mark function. But it's not working, the value returned is not the same as in struct.
#include <stdio.h>
struct lab {
double experiment1;
double experiment2;
double experiment3;
};
struct theory{
double test;
double final;
};
struct ele709_record{
struct lab lab_mark;
struct theory theory_mark;
};
double total_mark(struct ele709_record *p)
{
double totalmark;
p->lab_mark.experiment1 = totalmark;
return totalmark;
}
int main()
{
double john_doe_mark;
struct ele709_record john_doe;
john_doe.lab_mark.experiment1= 90.2;
john_doe.lab_mark.experiment2= 70.5;
john_doe.lab_mark.experiment3= 80.4;
john_doe.theory_mark.test= 82.3;
john_doe.theory_mark.final=79.2;
john_doe_mark = total_mark(&john_doe);
printf("this is his mark %lf\n",john_doe_mark);
}
#include <stdio.h>
struct lab {
double experiment1;
double experiment2;
double experiment3;
};
struct theory{
double test;
double final;
};
struct ele709_record{
struct lab lab_mark;
struct theory theory_mark;
};
double total_mark(struct ele709_record *p)
{
double totalmark;
p->lab_mark.experiment1 = totalmark;
return totalmark;
}
int main()
{
double john_doe_mark;
struct ele709_record john_doe;
john_doe.lab_mark.experiment1= 90.2;
john_doe.lab_mark.experiment2= 70.5;
john_doe.lab_mark.experiment3= 80.4;
john_doe.theory_mark.test= 82.3;
john_doe.theory_mark.final=79.2;
john_doe_mark = total_mark(&john_doe);
printf("this is his mark %lf\n",john_doe_mark);
}