본문 바로가기
Programming/C++

Array initialization and declaration at the same time

by OKOK 2017. 3. 9.

/*

위와 같은 예제이나 배열의 생성과 초기값 설정을 동시에 하기

*/


#include<stdio.h>


int main(void)

{

double total;

double val[5] = { 1.01, 2.02, 3.03, 4.04, 5.05 };


total = val[0] + val[1] + val[2] + val[3] + val[4];

printf("평균 : %lf\n", total / 5);


return 0;

}