1 /* 2 * Read and evaluate student test scores 3 */ 4 #include <stdio.h> 5 6 /* Display a notice regarding average test score 7 3 test scores are required as parameters */ 8 void GiveNotice (int score1, int score2, int score3) 9 { 10 /* Are the scores all positive? */ 11 if (score1 >= 0 && score2 >= 0 && score3 >= 0) 12 { 13 /* Compute average score */ 14 double Average = (score1 + score2 + score3) / 3.0; 15 printf ("Average score is %.1f -- ", Average ); 16 17 /* Display a message depending on range the score falls in */ 18 if (Average >= 60.0) 19 { 20 printf ("Passing"); 21 if (Average < 70.0) 22 { 23 printf (" but marginal"); 24 } 25 printf ("."); 26 } 27 else 28 { 29 printf ("Failing."); 30 } 31 } 32 /* Display invalid data message */ 33 else 34 { 35 printf ("Invalid data: score less than zero."); 36 } 37 38 } 39 40 int main (void) 41 { 42 int IDnum; /* Student ID number */ 43 int score1; /* Score on first test */ 44 int score2; /* Score on second test */ 45 int score3; /* Score on third test */ 46 47 /* Obtain input */ 48 printf("Enter a Student ID number and three test scores: "); 49 scanf ("%d%d%d%d",&IDnum,&score1,&score2,&score3); 50 51 /* Echo the input data */ 52 printf("Student number: %d \n", IDnum); 53 printf("Test Scores: %d %d %d \n",score1,score2,score3 ); 54 55 /* Go do the calculations */ 56 GiveNotice (score1, score2, score3); 57 return 0; 58 }