I have the following code which shows me the data of N number of employees admitted My question is this: How do I show the number of employees by sex?
int main(void){
/*Declara las variables para los ciclo for*/
int i = 0, n = 0;
/*Declara estructura person*/
struct person{
char dni[14];
char civil_status[15];
char sex[15];
};
/*Declara employee, arreglo de la estructura person*/
struct person employee[max];
/*Se pide cuantos registros de employees se guardaran*/
cout<<"Cuantos datos quieres ingresar? \n";
cin>> n;
/*Ciclo for que va a recorrer según la cantidad escrita anteriormente*/
for (i = 0; i < n; i++){
cout<<"\n Escriba la Cedula "<< i+1<<":";
cin>> employee[i].dni;
cout<<"\n Escriba el Estado Civil "<< i+1<<":";
cin>> employee[i].civil_status;
cout<<"\n Escriba el Sexo "<< i+1<<":";
cin>> employee[i].sex;
}
cout<<"\n El registro de employes que se introdujeron son: \n\n";
/*Ciclo for que muestra el listado de registro ingresados*/
for (i = 0; i < n; i++){
/*Se llama al arreglo employee seguido de la variable dni*/
cout<< employee[i].dni;
cout<<"\t"<<employee[i].civil_status;
cout<<"\t"<<employee[i].sex<<"\n\n";
}
system("pause");
}
An example of data entry:
How many data do you want to enter? 2
Write the Cedula 1: 012345
Write the Civil Status 1: single
Write Sex 1: male
Write the Certificate 2: 67891
Write Marital Status 2: married
Write the Sex 2: female
The register of employes that were introduced are:
012345 male bachelor 67891 married female