Created
August 7, 2019 23:49
-
-
Save parzibyte/22ec1cd2e14b7c8553934cdafd372aa1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(int argc, char const *argv[]) | |
{ | |
// Aquí almacenaremos los 5 números | |
int numeros[5]; | |
for (int i = 0; i < 5; ++i) | |
{ | |
printf("Por favor, ingresa el numero %d:\n", i + 1); // Sumar 1 porque empezamos desde 0 | |
scanf("%d", &numeros[i]); | |
} | |
//Suponemos que el mayor es el primer número | |
int numeroMayor = numeros[0]; | |
// Comenzar desde el 1, porque estamos suponiendo que el 0 es el mayor | |
for (int indice = 1; indice < 5; ++indice) | |
{ | |
int numeroActual = numeros[indice]; | |
if (numeroActual > numeroMayor){ | |
// Cambiar únicamente si el actual es mayor que numeroMayor | |
numeroMayor = numeroActual; | |
} | |
} | |
printf("De los 5 numeros que proporcionaste, el mayor es %d\n", numeroMayor); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment