WSQ10

#include <iostream>
#include <cmath>

using namespace std;

int suma (int numeros[], int x){
int suma=0;
for(int i=1; i<=x; i++){
suma=suma+numeros[i];
}
return (suma);
}

float DE (int numeros[], int p, int x){
float des;
float var =0.0;

for(int i=1; i<=x; i++){
var=var+ pow(p-numeros[i],2);
}
cout << var<< endl;
var=var/n-1;
des=sqrt(var);
return (des);
}

int main (){
//int num;
int n, prom, s;
int nums[n];

cout << “cuantos numeros quieres insertar?” << endl;
cin >> n;
cout << “Inserta “<< n << “numeros” << endl;

for (int i=1; i<=n; i++){
cin >> nums[i];
}

s=suma(nums, n);
prom = s/n;
cout <<“El promedio de esos numeros es: “<< prom << endl;
cout << “desviacion estandar es ” << DE (nums, prom, n)<< endl;
return 0;
}

CC BY-SA 4.0 WSQ10 by codemaster2016 is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.