-
Notifications
You must be signed in to change notification settings - Fork 0
/
q1quiz7.cpp
65 lines (46 loc) · 1.15 KB
/
q1quiz7.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <cmath>
using namespace std;
float calcular_promedio (float array [], int size) {
int i;
float promedio;
int suma = 0;
for (int i = 0; i <= size; i++){
suma = suma + array[i];
}
promedio = suma/size;
return promedio;
}
int calcular_suma(float a[], int size){
int total = 0;
for (int i = 0; i < size; i++){
total = total + a[i];
}
return total;
}
int calcular_desviacion(float sum, float promedio, int size, float array[]) {
//float deviation;
for (int i = 0; i < size; i++){
sum=sum+pow(array[i]-promedio,2);
}
return sqrt(sum/size);
}
int main(){
float promedio;
float sum;
float suma;
float deviation;
int size = 5;
float array[size];
for (int i = 0; i <size; i++){
cout << "Give me the variables" << endl;
cin >> array[i];
}
suma = calcular_suma(array,size);
promedio = calcular_promedio(array, size);
deviation = calcular_desviacion(sum,promedio,size,array);
cout <<"The sum of the numbers is " << suma << endl;
cout << "The average of the numbers is " << promedio << endl;
cout << "The standard deviation is " << deviation << endl;
return 0;
}