Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*******************************************************************************
- Condicionales, switchs, bucles, centinelas y banderas
- by
- Marcos Andrés Huck
- 2013 - UTN-FRP
- www.marcoshuck.com
- *******************************************************************************/
- #include <stdio.h>
- #include <stdlib.h>
- #define MAX_COMP 50
- #define MIN_COMP 100
- int main(int argc, char *argv[])
- {
- float num = 0, /* Número ingresado */
- suma = 0, /* Suma de los números ingresados */
- promedio = 0; /* Promedio de los números ingresados */
- int cont_in = 0, /* Contador de los números */
- cont_rango = 0, /* Contador de los números dentro del rango */
- flag = 0;/* Bandera para salida del búcle */
- do
- {
- printf("Ingrese el valor [%d]: ", cont_in+1);
- scanf("%f", &num);
- if(num != -1)
- {
- suma += num;
- cont_in++;
- if((num > MIN_COMP) && (num < MAX_COMP))
- {
- cont_rango++;
- }
- }
- else
- {
- flag = 1;
- }
- }
- while(flag == 0);
- promedio = suma/cont_in;
- printf("Numeros ingresados: %d\nSuma total: %.3f\nPromedio: %.3f\nCantidad de numeros comprendidos entre 50 y 100: %d\n", cont_in, suma, promedio, cont_rango);
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment