Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created October 16, 2019 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/521efcf1bf6caf8fc084fd7b606afc2b to your computer and use it in GitHub Desktop.
Save parzibyte/521efcf1bf6caf8fc084fd7b606afc2b to your computer and use it in GitHub Desktop.
int main(void) {
// El arreglo en donde buscamos
int edades[] = {23, 25, 30, 15, 2};
// El valor que buscamos
int busqueda = 25;
// La longitud; puedes indicarla manualmente o calcularla con
// sizeof como se ve en https://parzibyte.me/blog/2018/09/21/longitud-de-un-arreglo-en-c/
int longitud = sizeof edades / sizeof edades[0];
int existe = buscarEnArreglo(edades, busqueda, longitud);
printf("Posicion de %d en arreglo: %d", busqueda, existe);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment