Advertising
- Anonymous
- Wednesday, May 23rd, 2012 at 8:50:33pm MDT
- int main()
- {
- int midterm, final, average, std_num = 1;
- int repeat = 1;
- char grade = 'E';
- struct student *curr, *head, *root;
- char name[20] = "";
- head = NULL;
- while(std_num < 11) {
- //1)Request user input and
- printf("\nPlease give the name of student %d: ", std_num);
- do
- {
- fgets(name, 20, stdin );
- } while(name[0] == '\n');
- //Get student name
- //Get student midterm
- printf("\nMidterm grade: ");
- scanf("%d", &midterm);
- //Get student final
- printf("\nFinal grade: ");
- scanf("%d", &final);
- //Store in linked list
- if(std_num == 1) {
- root = malloc(sizeof(struct student));
- curr = root;
- } else {
- curr = malloc(sizeof(struct student) );
- }
- curr->next = head;
- curr->name = name;
- curr->midterm = midterm;
- curr->final = final;
- //head = curr;
- average = final_score(curr);
- grade = final_grade(curr);
- curr->average = average;
- curr->grade = grade;
- printf("Stuff: %d, %d", average, curr->final);
- std_num++;
- //curr = head;
- printf("\nAdd another student? Type n to exit: ");
- char contin ='t';
- scanf(" %c", &contin);
- if((char)contin == 'n')
- {
- std_num = 20;
- //curr = start;
- printf("\n END: %d, %d, %c", root->midterm, root->final, root->grade);
- }
- //temp->next = malloc(sizeof(struct student));
- //temp = temp->student;
- // struct student std = {name, midterm, final, 0, 'E'};
- //Finished? If n, repeat. If i >=10, or y, end
- }
- curr = root;
- //Compute every student's average
- //Sort list
- printf("start");
- //sort_grades(curr);
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.