Advertisement
weldisalves

2ª Prova(simulado) - Exercício 02

Jul 5th, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <math.h>
  4.  
  5. int main()
  6. {
  7.     int quantValores,i;
  8.  
  9.     printf("\n Digite a quantidade de valores: ");
  10.     scanf("%d",&quantValores);
  11.  
  12.     float listaDeNumeros[quantValores],somaValores=0,media,desvioPadrao,soma=0;
  13.  
  14.     for(i=0;i<quantValores;i++)
  15.     {
  16.         printf("\n Digite um valor: ");
  17.         scanf("%f",&listaDeNumeros[i]);
  18.         somaValores += listaDeNumeros[i];
  19.     }
  20.  
  21.     media=somaValores/quantValores;
  22.  
  23.     for(i=0;i<quantValores;i++)
  24.     {
  25.         soma += pow((listaDeNumeros[i]-media),2);
  26.     }
  27.  
  28.     desvioPadrao = sqrt((1.0/(quantValores-1))*soma);
  29.  
  30.     printf("\n Desvio padrao = %.3f",desvioPadrao);
  31.  
  32.     getch();
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement