C++ cin read five numbers entered using for loop
#include <iostream> using namespace std; int main()/* ww w . ja va 2 s . c o m*/ { const int MAXNUMS = 5; int i; double usenum, positiveSum, negativeSum; positiveSum = 0; // this initialization can be done in the declaration negativeSum = 0; // this initialization can be done in the declaration for (i = 1; i <= MAXNUMS; i++) { cout << "Enter a number (positive or negative) : "; cin >> usenum; if (usenum > 0) positiveSum = positiveSum + usenum; else negativeSum = negativeSum + usenum; } cout << "The positive total is " << positiveSum << endl; cout << "The negative total is " << negativeSum << endl; return 0; }