-
-
Save parzibyte/4a496be7b8ab2058fd0f5e04d714fe48 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 <iostream> | |
using namespace std; | |
bool esPrimo(int numero) | |
{ | |
if (numero == 0 || numero == 1 || numero == 4) | |
{ | |
return false; | |
} | |
for (int x = 2; x < numero / 2; x++) | |
{ | |
if (numero % x == 0) | |
{ | |
return false; | |
} | |
} | |
return true; | |
} | |
int main() | |
{ | |
int cantidad = 10; | |
int arreglo[cantidad]; | |
int i; | |
for (i = 0; i < cantidad; i++) | |
{ | |
cout << "Ingresa el numero que va en la posicion " << i+1 << ": "; | |
cin >> arreglo[i]; | |
} | |
for (i = 0; i < cantidad; i++) | |
{ | |
int numero = arreglo[i]; | |
if(esPrimo(numero)){ | |
cout << numero << " es primo\n"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment