Generation

generate functionSat, 27 May 2023

escriba un programa en c++ usando for que pregunte cuantos numeros se van a introducir, pida esos numeros y escriba el mayor, el menor y la media aritmetica

#include <iostream> using namespace std; int main() { int i, j, n, a[10]; float total = 0; float media; cout << "Cuantos numeros se van a ingresar? "; cin >> n; for (i=0;i<n;i++){ cout << "Ingrese el numero " << i + 1 << endl; cin >> a[i]; } int max = 0; int min = 0; for (j=0;j<n;j++){ if (a[j] > max){ max = a[j]; } if (a[j] < min){ min = a[j]; } } cout << "El numero mayor es: " << max << endl; cout << "El numero menor es: " << min << endl;

Want to kickstart your project?Use the new AI Studio to create your code