Advertisement
GhostTV

Notendurchschnitt

Dec 3rd, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void){
  4.     float Summe = 0;
  5.     int Anzahl = 0;
  6.     float Note;
  7.     float Durchschnitt;
  8.    
  9.     scanf("%f",&Note);
  10.    
  11.     while(Note != 0)
  12.     {
  13.        
  14.         if(Note > 0 && Note <=6)
  15.         {
  16.             Summe = Summe + Note;
  17.             Anzahl++;
  18.         }
  19.         else
  20.         {
  21.             printf("Nur Ziffern von 1-6!");
  22.         }
  23.        
  24.         scanf("%f",&Note);
  25.  
  26.     }
  27.    
  28.     if(Anzahl >= 2)
  29.     {
  30.         Durchschnitt = Summe / Anzahl;
  31.         printf("%.2f",Durchschnitt);
  32.     }
  33.     else
  34.     {
  35.         printf("Zu wenige Noteneingaben");
  36.     }
  37.    
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement