Advertisement
Kl43z

While / Media

Sep 23rd, 2014
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4. int num=0,resp=0,cont=0;
  5. float media=0,suma=0;
  6.  
  7. printf("Desea ingresar un numero SI(1) - NO(0)");
  8. scanf("%d", &resp);
  9. while (resp==1){
  10. printf ("Ingrese un numero para sumar \n");
  11. scanf ("%i", &num);
  12. suma+=suma+num;
  13. cont++;
  14. printf ("Desea ingresar otro numero SI(1) NO(0)");
  15. scanf ("%i", &resp);
  16. }
  17. media=suma/cont;
  18. printf("La media es: %f\n", media);
  19. return 0;
  20.  
  21.  
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement