Anderson Pozo

Generation

generate functionMon, 24 Jul 2023

Hacer un programa para ingresar cinco números y listar cuántos de esos cinco números son positivos.

#include <iostream> using std::cout; using std::cin; using std::endl; int main(int argc, char const *argv[]) { int a, b, c, d, e, nPositive=0; cout << "Enter five numbers: "; cin >> a >> b >> c >> d >> e; if (a > 0) nPositive++; if (b > 0) nPositive++; if (c > 0) nPositive++; if (d > 0) nPositive++; if (e > 0) nPositive++; cout << "Number of positive numbers is: " << nPositive; return 0; }

Questions about programming?Chat with your personal AI assistant