Good Night I have the following exercise in which I require that in the end I print the data (Name and Age) of people over 60 years.
Until the moment it does not do it correctly and it prints all the cases and of step the age is not the indicated one if not other numbers. How could I solve it?
int main(int argc, char const *argv[])
{
int i = 0, cpersonas_tercera = 0, edad[2], edad_tercera[2];
float tercera_edad = 0, promedio;
char nombre[2][30];
for (int i = 1; i <= 2; i++)
{
system("cls");
cout<<"< = = = D A T O S P E R S O N A L E S = = = >";
cout<<"\n\nNombre: ";
cin>>nombre[i];
cout<<"\nEdad: ";
cin>>edad[i];
if (edad[i] >= 60)
{
cpersonas_tercera++;
tercera_edad = tercera_edad + edad[i];
}
}
promedio = tercera_edad / cpersonas_tercera;
system("cls");
cout<<fixed<<setprecision(2);
cout<<"< = = = D A T O S R E C O L E C T A D O S = = = >";
cout<<"\n\nCantidad de Personas de Tercera Edad (+60 Años): "<<cpersonas_tercera;
cout<<"\n\nPromedio de la Tercera Edad (+60 Años): "<<promedio;
for (i = 1 ; i <= 2 ; i++)
{
if (edad[i] >= 60)
{
cout<<"\nNombre: "<<nombre[i];
cout<<"\nEdad: "<<edad[i];
}
}
return 0;
}