Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

Anonymous
Wednesday, May 23rd, 2012 at 8:50:33pm MDT 

  1. int main()
  2. {
  3.  
  4.   int midterm, final, average, std_num = 1;
  5.   int repeat = 1;
  6.   char grade = 'E';
  7.  
  8.   struct student *curr, *head, *root;
  9.  
  10.   char name[20] = "";
  11.  
  12.   head = NULL;
  13.  
  14.  
  15.  
  16.   while(std_num < 11) {
  17.         //1)Request user input and
  18.  
  19.     printf("\nPlease give the name of student %d: ", std_num);
  20.  
  21.     do
  22.       {
  23.         fgets(name, 20, stdin );
  24.  
  25.       } while(name[0] == '\n');
  26.    
  27.    
  28.  
  29.   //Get student name
  30.  
  31.   //Get student midterm
  32.     printf("\nMidterm grade: ");
  33.     scanf("%d", &midterm);
  34.  
  35.  
  36.  
  37.   //Get student final
  38.  
  39.     printf("\nFinal grade: ");
  40.     scanf("%d", &final);
  41.  
  42.    
  43.    
  44.   //Store in linked list
  45.  
  46.     if(std_num == 1) {
  47.  
  48.       root = malloc(sizeof(struct student));
  49.       curr = root;
  50.     } else {
  51.  
  52.       curr = malloc(sizeof(struct student) );
  53.  
  54.     }
  55.  
  56.     curr->next = head;
  57.     curr->name = name;
  58.     curr->midterm = midterm;
  59.     curr->final = final;
  60.     //head = curr;
  61.  
  62.     average = final_score(curr);
  63.  
  64.     grade = final_grade(curr);
  65.  
  66.     curr->average = average;
  67.     curr->grade = grade;
  68.  
  69.     printf("Stuff: %d, %d", average, curr->final);
  70.  
  71.     std_num++;
  72.  
  73.     //curr = head;
  74.    
  75.  
  76.     printf("\nAdd another student? Type n to exit: ");
  77.  
  78.     char contin ='t';
  79.         scanf(" %c", &contin);
  80.         if((char)contin == 'n')
  81.         {
  82.           std_num = 20;
  83.           //curr = start;
  84.           printf("\n END: %d, %d, %c", root->midterm, root->final, root->grade);
  85.         }
  86.     //temp->next = malloc(sizeof(struct student));
  87.     //temp = temp->student;
  88.  
  89.    
  90.  
  91.     // struct student std = {name, midterm, final, 0, 'E'};
  92.  
  93.   //Finished? If n, repeat. If i >=10, or y, end
  94.  
  95.   }
  96.  
  97.   curr = root;
  98.  
  99.  
  100.   //Compute every student's average
  101.  
  102.   //Sort list
  103.  
  104.   printf("start");
  105.   //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.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



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.

worth-right
fantasy-obligation