Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- main(){
- FILE* fichero;
- fichero=fopen("historial.txt", "a+t");
- int edad;
- int menores = 0;
- int mayores = 0;
- int personas = 0;
- int etotal = 0;
- int dia, mes, anio;
- float epromedio;
- printf("Ingrese dia: ");
- scanf("%i", &dia);
- printf("Ingrese mes: ");
- scanf("%i", &mes);
- printf("Ingrese anio: ");
- scanf("%i", &anio);
- do{
- printf("\n Ingrese una edad: ");
- scanf("%i", &edad);
- if(edad < 18 && edad > 0){
- etotal += edad;
- personas++;
- menores++;
- printf("Es menor. Hay %i menor/es y %i mayor/es.\n", menores, mayores);
- }else if(edad >= 18){
- etotal += edad;
- personas++;
- mayores++;
- printf("Es mayor. Hay %i menor/es y %i mayor/es.\n", menores, mayores);
- }
- }while(edad != 0);
- epromedio = etotal/personas;
- fprintf(fichero, "\nFecha: %i-%i-%i. Cant total personas: %i. Cantidad mayores: %i. Cantidad menores: %i. Edad promedio %.2f", dia,mes,anio,personas, mayores,menores, epromedio);
- fclose(fichero);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement