### Help with Functions and Loop

Pages: 12
Even just for the addition of all input and the average of it. It's the hardest I can ever think of.
Everything is working so far... I think.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124`` ``````#include using namespace std; int sumofpositive ( int z, int x) // Sum of Negative { if (x > 0) z += x; return z; } int sumofnegative ( int z, int x) // Sum of Negative { if (x < 0) z += x; return z; } int positive (int z, int x) // Positive value { if (x > 0) z++; return z; } int negative (int z, int x) // Negative value { if (x < 0) z++; return z; } int zero (int z, int x) // Zero value { if (x == 0) z++; return z; } int odd (int z, int x) // Odd value { if (x %2==!0) z++; return z; } int even (int z, int x) // Even value { if (x>0 && x %2== 0) z++; return z; } int noteo (int z, int x) // Not Even nor Odd value { if (x < 0) z++; return z; } int addition (int z, int x) // Sum of All Inputs { z += x; return z; } int main () { int ctr=0, unk=1; // For loop int n, num; // For looping input/output int a=0, b=0; // For the Sum of all Positive and Negative integers int c=0, d=0, e=0; // For Positive, Negative and Zero value int f=0, g=0, h=0; // For Odd, Even and Not Even nor Odd value int i=0; // For the sum all input integers cout << "Please enter input size: "; cin >> n; cout << endl; cout << endl; for (ctr=0; ctr> num; a = sumofpositive (a, num); b = sumofnegative (b, num); c = positive (c, num); d = negative (d, num); e = zero (e, num); f = odd (f, num); g = even (g, num); h = noteo (h, num); i = addition (i, num); } cout << endl << "Number of Positive Integer(s): " << c; cout << endl << "Number of Negative Integer(s): " << d; cout << endl << "Number of Zero(es): " << e; cout << endl; cout << endl << "Number of Odd Integer(s): " << f; cout << endl << "Number of Even Integer(s): " << g; cout << endl << "Number of Not Even nor Odd Integer(s): " << h; cout << endl; cout << endl << "The sum of all Positive Integers: " << a; cout << endl << "The sum of all Negative Integers: " << b; cout << endl << "The sum of all input integers: " << i; cout << endl; cout << endl; system ("pause"); }``````

Topic archived. No new replies allowed.
Pages: 12