Generation

generate functionTue, 16 May 2023

Leer 12 números desde el teclado y mostrar cuantos números fueron positivos, cuantos negativos y cuantos ceros.

int positivos, negativos, ceros; int numero; positivos = negativos = ceros = 0; for (int i = 0; i < 12; i++) { cout << "Ingresa un numero: "; cin >> numero; if (numero < 0) { negativos++; } else if (numero > 0) { positivos++; } else { ceros++; } } cout << "Positivos: " << positivos << endl; cout << "Negativos: " << negativos << endl; cout << "Ceros: " << ceros << endl;

Questions about programming?Chat with your personal AI assistant