Advertisement
MUstar

IoT C언어 0522 - 8-4

May 22nd, 2017
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5.     int score[5];
  6.     int i;
  7.     int tot =0;
  8.     double avg;
  9.     int cnt;
  10.  
  11.     cnt = sizeof(score) / sizeof(score[0]);
  12.  
  13.     for(i = 0; i < cnt; i++)
  14.     {
  15.         scanf("%d", &score[i]);
  16.     }
  17.  
  18.     for(i = 0; i < cnt; i++)
  19.     {
  20.         tot += score[i];
  21.     }
  22.     avg = tot / (double)cnt;
  23.  
  24.     for(i = 0; i < cnt; i++)
  25.     {
  26.         printf("%5d",score[i]);
  27.     }
  28.     printf("\n");
  29.  
  30.     printf("평균 : %.1lf\n", avg);
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement