Created
July 5, 2010 14:09
-
-
Save Mistat/464382 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 課題2 | |
| * | |
| * 5つの配列を格納する配列Dataに任意の5つの数字を格納(初期値設定)して、 | |
| * 合計と平均を求めるプログラムを作成 | |
| */ | |
| #include<stdio.h> | |
| void main() | |
| { | |
| //配列の宣言とデータの初期値設定 | |
| int array[] = {10,20,30,40,50}; | |
| double sum=0,ave=0; | |
| int i; | |
| //合計の計算 | |
| //平均の計算 | |
| for (i = 0 ; i < 5 ; i++) { | |
| sum += array[i]; | |
| } | |
| ave = sum / 5; | |
| //計算の結果表示 | |
| printf("sum = %.5f, ave = %.5f\n", sum, ave); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment