Advertisement
lButcherl

Vetor 01

Oct 25th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1. // 1. Construa um algoritmo que leia um vetor de 10 posições e calcule a média destes valores. Na sequência,
  2. //apresente na tela os valores que são iguais ou superiores à média.
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #define tam 10
  7.  
  8. main()
  9. {
  10.       int i;
  11.       float var[tam], soma = 0, media;
  12.       for(i=0;i<tam;i++){
  13.                          printf("Informe os valores: ");
  14.                          scanf("%f",&var[i]);
  15.                          soma = soma + var[i];
  16.                          }
  17.                          media = soma / tam;
  18.                          for (i=0;i<tam;i++){
  19.                              if (var[i] >= media){
  20.                                         printf("%f\n",var[i]);
  21.                                         }
  22.                                         }
  23.                          printf("%f",media);
  24.                          system("pause");
  25.                          }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement