thenewboston

C Programming Tutorial - 20 - What about more than two...

Aug 22nd, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     float grade1;
  7.     float grade2;
  8.     float grade3;
  9.  
  10.     printf("Enter your 3 grades:\n");
  11.     scanf("%f", &grade1);
  12.     scanf("%f", &grade2);
  13.     scanf("%f", &grade3);
  14.  
  15.     float avg = (grade1+grade2+grade3)/3;
  16.     printf("Average: %.2f \n", avg);
  17.  
  18.     if(avg >= 90){
  19.         printf("Grade: A");
  20.     }else if(avg >= 80){
  21.         printf("Grade: B");
  22.     }else if(avg >= 70){
  23.         printf("Grade: C");
  24.     }else if(avg >= 60){
  25.         printf("Grade: D");
  26.     }else{
  27.         printf("You are dumb.");
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment