Creative Code

procScore.c (배열 성적평균구하기) 본문

C Programming

procScore.c (배열 성적평균구하기)

빛하루 2023. 8. 1. 16:38
#include <stdio.h>

int main(void)
{
	int scores[5];
    for (int i = 0; i<5; i++) {
    	scanf("%d",&scores[i]);
    }
    int total = 0;
    for (int i =0; i<5; i++) {
    	total += scores[i];
    }
    double average = (double)total/5.0;
    printf("total : %d\t average : %.2f\n",total,average);
    return 0;
}