Hi, I dont really know how to write the function to compute the final score, which is equal to 0.75(quiz1+quiz2+quiz3)+0.25(exam1+exam2+exam3).
Code:#include<stdio.h> #define NAME 25 #define SOCIAL 12 #define PHONE 15 #define QUIZ 13 #define EXAM 13 #define FINAL 3 #define SIZE 2 struct { char first[NAME]; char last[NAME]; }typedef Name; struct { int first3; int middle2; int last4; }typedef Social; struct { int code; int first3; int last4; }typedef Phone; struct { int quiz1[QUIZ]; int quiz2[QUIZ]; int quiz3[QUIZ]; }typedef Quiz; struct { int exam1; int exam2; int exam3; }typedef Exam; struct { Name name; Social social; Phone phone; Quiz quiz; Exam exam; } typedef Grade; void enterGrade(Grade *cptr); int Final(int quiz int exam); int main() { Grade grade[SIZE]; int x; for(x=0;x<SIZE;x++); enterGrade(&grade); return 0; } void enterGrade(Grade *cptr) { printf("Enter first name: "); gets(cptr->name.first); printf("Enter last name: "); gets(cptr->name.last); printf("Enter social sercurity number: "); scanf("%s", &cptr->social.first3, &cptr->social.middle2, &cptr->social.last4); printf("Enter phone number: "); scanf("%s", &cptr->phone.code,&cptr->phone.first3,&cptr->phone.last4); printf("Enter 1st quiz score: "); scanf("%d", &cptr->quiz.quiz1); printf("Enter 2nd quiz score: "); scanf("%d", &cptr->quiz.quiz2); printf("Enter 3rd quiz score: "); scanf("%d", &cptr->quiz.quiz3); printf("Enter 1st exam score: "); scanf("%d", &cptr->exam.exam1); printf("Enter 2nd exam score: "); scanf("%d", &cptr->exam.exam2); printf("Enter 3rd exam score: "); scanf("%d", &cptr->exam.exam3); } int Final (int quiz int exam) { Final = 0.75(&cptr->quiz.quiz1+&cptr->quiz.quiz2+&cptr->quiz.quiz3)+ 0.25(&cptr->exam.exam1+&cptr->exam.exam2+&cptr->exam.exam3); return x; }



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.