### Help me :<

Using functions and given N input numbers, perform the following tasks:

find the sum and average
find the positive, negative and zero
find the odd, even and not odd nor even(negatives)
find the sum of all positive and negative

I don't even know if I am doing right, all those with /* */ are the codes that I can't do.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127`` `````` #include using namespace std; { int main() int add (int a, int b) // Addition { int z; z = (a+b); return z; } /* int ave (int a, int b) // Average { int y; y = (a+b); } */ int sump (int a, int b) // Sum of Positives { int x; if (a,b > 0) x = (a+b); return x; } int sumn (int a, int b) // Sum of Negatives { int w; if (a,b < 0) w = (a+b); return w; } int posi (int a) // Occurence of Positives { int v; if (a>0) v++; return v; } int nega (int a) // Occurence of Negatives { int u; if (a<0) u++; return u; } int zero (int a) // Occurence of Zeroes { int t; if (a==0) t++; return t; } int noteo (int a) // Occurence of Not Even Nor Odd { int s; if (a<0) s++; return s; } int even (int a) // Occurence of Even { int r; if (a%2==0) r++; return r; } int odd (int a) // Occurence of Odd { int q; if (a%2==!0) q++; return q; } { int ctr=0, unk=1; int n; cout << "Please enter input size: "; cin >> n; cout << endl; cout << endl; for (ctr=0; ctr> a&&b } cout << endl << "The sum of all integers: " << add; /* cout << endl << "The average of the sum of all integers: " << ave; */ cout << endl << "Number of Positive Integer(s): " << posi; cout << endl << "Number of Negative Integer(s): " <

*I actually get an error "8 expected `,' or `;' before '{' token" if I try to compile and run the code.
Last edited on
Just move the int main declaration from line 8 to 104.
Last edited on
Still the same error.
There's a random '{' on line 5.
Also, your 'posi', 'nega', 'zero', 'noteo', 'even' and 'odd' functions use variables which haven't been initialized.

EDIT dude you've got some serious bracket issues.
Last edited on
Even if I delete all the brackets and just leave 2 brackets to line 5 and line 127, the same issue occurs.
take out brackets at line 5 and line 86
and you should be fine post edited code if you have anymore problems
Error : 90 `,' or `;' before '<<' token

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126`` ``````#include using namespace std; int add (int a, int b) // Addition { int z; z = (a+b); return z; } /* int ave (int a, int b) // Average { int y; y = (a+b); } */ int sump (int a, int b) // Sum of Positives { int x; if (a,b > 0) x = (a+b); return x; } int sumn (int a, int b) // Sum of Negatives { int w; if (a,b < 0) w = (a+b); return w; } int posi (int a) // Occurence of Positives { int v; if (a>0) v++; return v; } int nega (int a) // Occurence of Negatives { int u; if (a<0) u++; return u; } int zero (int a) // Occurence of Zeroes { int t; if (a==0) t++; return t; } int noteo (int a) // Occurence of Not Even Nor Odd { int s; if (a<0) s++; return s; } int even (int a) // Occurence of Even { int r; if (a%2==0) r++; return r; } int odd (int a) // Occurence of Odd { int q; if (a%2==!0) q++; return q; } int ctr=0, unk=1; int n; cout << "Please enter input size: "; cin >> n; cout << endl; cout << endl; for (ctr=0; ctr> a&&b } int main() cout << endl << "The sum of all integers: " << add; /* cout << endl << "The average of the sum of all integers: " << ave; */ cout << endl << "Number of Positive Integer(s): " << posi; cout << endl << "Number of Negative Integer(s): " <

>_<

87-100 What is that code doing at global scope?
Last edited on
Since my function is full of fallacies, I'm just going to make a new one and will just let this thread unanswered. Please close.

Thanks to everyone!
Topic archived. No new replies allowed.