Anderson Pozo

Generation

generate functionSat, 24 Jun 2023

Dada una lista de 10 números enteros. Calcular e informar el primer número par, el primer número primo.

#include <iostream> #include <math.h> using namespace std; int main() { int i,j; int array[10]; for(i = 0; i <= 9; ++i) { cout << "Enter " << i << ": "; cin >> array[i]; } for(i = 0; i <= 9; ++i) { if(array[i]%2==0) { cout << "The first even number is: " << array[i] << endl; break; } } for(i = 0; i <= 9; ++i) { for(j = 2; j <= sqrt(array[i]); ++j) { if(array[i]%j==0) { break; } } if(j == sqrt(array[i])+1) { cout << "The first prime number is:

Questions about programming?Chat with your personal AI assistant