I made a program using functions in which you requested the age of the person, and added some conditions that if it is less than 12 years old it is childish and the cost is 300, if it is less than 18 years old it is considered childish and the cost is 500 and if it is over 18 years it is considered adult and the cost is 800. The program allows the entry of 10 people, however, I am not adding the positions I want for each condition, what I need is print how many people entered each category but it is not working the right way. Excuse me if you do not explain well.
#include <stdlib.h>
#include <conio.h>
#include <time.h>
#include <stdio.h>
void main ()
{
int edad[10];
int x,y,r;
printf ("BIENVENIDOS AL EVENTO\n");
for (x=0;x<=9;x++) //Guarda 10 edades
{
printf ("Ingrese las edades");
scanf (" %d",&edad[x]);
}
for (x=0;x<=9;x++)
{
printf (" %d",edad[x]);
}
r=evento(edad); //Llamando funcion
printf ("El total de los boletos es de %d",r);
}
void evento (int edad[]) //Recibe funcion
{
int suma=0, suma2=0, suma3=0;
int i,o = 300,x,h = 500,t = 800,p,q;
for (i=0; i < 10;i++) // Suma las posiciones que son menor a 13, aqui es donde no me esta dando, igual que en las otras condiciones.
{
if (edad[i] < 13)
{
suma = suma+i;
}
}
printf ("En infantil ingresaron %d personas\n",suma);
for (i=0;i<10;i++) // Suma las posiciones que son menor a 18
{
if (edad[i]<18)
{
suma2 = suma2+i;
}
}
printf ("En juvenil ingresaron %d personas\n",suma2);
for (i=0;i< 10;i++) // Suma las posiciones que son mayor a 18
{
if (edad[i]>18)
{
suma3=suma3+i;
}
}
printf ("Ingresaron %d adultos\n",suma3);
//q=h+o+t;
//return q;
}