Hello , im new to the forum this is my first post, i subscribed because im really new to programming and i was ask to do a program which gave the user 4 options , to do some random things(to practice what we have learned) but on option 3 i need to ask the user for the age (edad) of the employees and count them until the user don't want to enter another age , then i have to show the count of mature ones (maduros) , seniors (mayores) , and youngsters (jovenes) , pretty much all work right now except that youngsters (variable jovenes in the program) just won't increase the value it always output 0 . i hope some of you can tell me what im i doing wrong .
Thanks in advance.
Here is the code:
Code:
#include<stdio.h>
int main(){
int opcion;
printf("1.Capturar datos de la Empresa\n");
printf("2.Mostrar datos de la empresa\n");
printf("3.Edades de los empleados\n");
printf("4.Salir\n");
printf("\n");
while (opcion!=4){
int edad;
int mayores=0;
int maduros=0;
int jovenes=0;
char siono='y';
char salir='n';
printf("opcion: ");
scanf("%d",&opcion);
printf("\n");
char nombreEmpresa[60];
char giro[60];
switch (opcion){
case 1:
printf("Nombre de la empresa:");
scanf("%s",nombreEmpresa);
printf("Giro de la empresa:");
scanf("%s",giro);
printf("\n");
break;
case 2:
printf("Nombre de la empresa:%s", nombreEmpresa);
printf("\nGiro: %s",giro);
printf("\n\n");
break;
case 3:
while (siono != 'n'){
printf("Escriba la edad de los empleados: ");
scanf("%d",&edad);
if (edad<0){
printf("Error");
}
else if(edad>65){
printf("Error\n\n");
}
else if(edad>=50){
mayores++;
}
else if(edad>=22){
maduros++;
}
else if(edad>=18){
jovenes++;
}
else{
printf("Error\n\n");
}
printf("Desea ingresar otra edad? y/n ");
scanf ("%s",&siono);
printf("\n");
}
printf("Mayores: %d\n",mayores);
printf("Maduros: %d\n",maduros);
printf("Jovenes: %d\n",jovenes);
printf("\n");
break;
case 4:
while (salir !='y'){
printf("Realmente desea salir? y/n ");
scanf("%s", &salir);
if(salir=='n'){
salir='y';
opcion=5;
printf("\n");
}
}
break;
default:
printf("\n");
break;
}
}
return 0;
}