1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
#include <iostream>
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<n; ctr++)
{
cout << "Enter the integer value " << (unk++) << ": ";
cin >> 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");
}
|