training

Code I wrote during training
git clone git://git.bitsmanent.org/training
Log | Files | Refs | README

qualityPoints.c (639B)


      1 /* Exercise 5.30 */
      2 
      3 #include <stdio.h>
      4 
      5 int qualityPoints(int);
      6 
      7 int main()
      8 {
      9    int average;
     10 
     11    printf("Give me your average: ");
     12    scanf("%d", &average);
     13 
     14    printf("Your score is %d.\n", qualityPoints(average));
     15 
     16    return 0;
     17 } /* E0F main */
     18 
     19 /* return a score depending of average */
     20 int qualityPoints(int avr)
     21 {
     22    if(avr > 100) /* He/she is a genius :-) */
     23       return 100;
     24 
     25    if(avr >= 90 && avr <= 100)
     26       return 4;
     27    else if(avr >= 80 && avr <= 89)
     28       return 3;
     29    else if(avr >= 70 && avr <= 79)
     30       return 2;
     31    else if(avr >= 60 && avr <= 69)
     32       return 1;
     33    else
     34       return 0;
     35 } /* eof qualityPoints() */
     36