Anderson Pozo

Generation

generate functionThu, 22 Jun 2023

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

#include <stdio.h> #include <iostream> #include <math.h> using namespace std; //function that: add tewo numbers together int add(int a, int b) { return a + b; } //function that: divide two numbers float divide(float a, float b) { if(b == 0) { cout << "divide by zero error" << endl; return 0; } return a/b; } //function that: returns the first even number in a list int firstEvenNumber(int list[], int length) { for(int i = 0; i < length; i++) { if(list[i] % 2 == 0) { return list[i]; } } return 0; } //function that: returns the first prime number in a list int firstPrimeNumber(int list[], int length) { for(int i = 0;

Questions about programming?Chat with your personal AI assistant