moranguinho

ex9ER3

Apr 12th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. /* 9) Ler dois valores que representam os limites de um intervalo. Apresentar os valores
  2. separados por tabulação. Fazer a média dos valores que são divisíveis por 11 e por 7,
  3. desse intervalo. */
  4. #include <stdio.h>
  5. int main(void)
  6. {
  7. int i, l1, l2, soma=0, qtd=0;
  8. float media;
  9.  
  10. printf("Informe o primeiro limite: ");
  11. scanf("%d", &l1);
  12. printf("Informe o segundo limite: ");
  13. scanf("%d", &l2);
  14.  
  15. for(i=l1; i<=l2;i++)
  16. {
  17. printf("%d\t", i);
  18. if (i%7==0 && i%11==0)
  19. {
  20. soma = soma + i;
  21. qtd++;
  22. }
  23. }
  24. media = (float)soma/qtd;
  25. printf("\nMedia: %.2f", media);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment