Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 7, 2019 23:49
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/f21ffa50da1d8acc74c9470d9bc90172 to your computer and use it in GitHub Desktop.
Save parzibyte/f21ffa50da1d8acc74c9470d9bc90172 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(int argc, char const *argv[])
{
// Aquí almacenaremos los 3 números
int numeros[3];
for (int i = 0; i < 3; ++i)
{
printf("Por favor, ingresa el numero %d:\n", i + 1); // Sumar 1 porque empezamos desde 0
scanf("%d", &numeros[i]);
}
//Suponemos que el menor es el primer número
int numeroMenor = numeros[0];
// Comenzar desde el 1, porque estamos suponiendo que el 0 es el menor
for (int indice = 1; indice < 3; ++indice)
{
int numeroActual = numeros[indice];
if (numeroActual < numeroMenor){
// Cambiar únicamente si el actual es menor que numeroMenor
numeroMenor = numeroActual;
}
}
printf("De los 3 numeros que proporcionaste, el menor es %d\n", numeroMenor);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment