moranguinho

ex5ER3

Apr 12th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. /* 5) Mostrar os valores ímpares e não divisíveis por 5 entre 200 e 0. Apresentar os valores
  2. em ordem decrescente. Fazer a média dos valores desse intervalo que são divisíveis por 3
  3. e por 5. */
  4. #include <stdio.h>
  5. int main(void)
  6. {
  7. int i, div, soma=0, qtd=0;
  8. float media;
  9.  
  10. for (i=200; i>=0;i--)
  11. {
  12. if(i%2!=0 && i%5!=0)
  13. {
  14. printf("%d\t", i);
  15. }
  16. if (i%3 == 0 && i%5==0)
  17. {
  18. soma = soma + i;
  19. qtd++;
  20. }
  21. }
  22. media = (float)soma/qtd;
  23. printf("%.2f\t", media);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment