Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 9) Ler dois valores que representam os limites de um intervalo. Apresentar os valores
- separados por tabulação. Fazer a média dos valores que são divisíveis por 11 e por 7,
- desse intervalo. */
- #include <stdio.h>
- int main(void)
- {
- int i, l1, l2, soma=0, qtd=0;
- float media;
- printf("Informe o primeiro limite: ");
- scanf("%d", &l1);
- printf("Informe o segundo limite: ");
- scanf("%d", &l2);
- for(i=l1; i<=l2;i++)
- {
- printf("%d\t", i);
- if (i%7==0 && i%11==0)
- {
- soma = soma + i;
- qtd++;
- }
- }
- media = (float)soma/qtd;
- printf("\nMedia: %.2f", media);
- }
Advertisement
Add Comment
Please, Sign In to add comment