[ create a new paste ] login | about

Link: http://codepad.org/zv9Zmt9o    [ raw code | output | fork ]

C++, pasted on Nov 7:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>

#define N 14

int main(int argc, char* argv[])
{
	double M[N] = { 3.5, 4.7, 9.6, 2.8, 6.4, 3.8, 4.1, 1.2, 2.7, 9.4, 2.6, 4.5, 7.3, 8.4 };

	for (int t1 = 0; t1 < N; t1++)
		printf("%4.2f ",M[t1]);

	printf("\n\n");

	double avg = 0;
	for (int i = 0; i < N; i++)
		avg+=(double)M[i] / N;

	printf("avg = %4.2f\n", avg);
}


Output:
1
2
3
3.50 4.70 9.60 2.80 6.40 3.80 4.10 1.20 2.70 9.40 2.60 4.50 7.30 8.40 

avg = 5.07


Create a new paste based on this one


Comments: