0

Hi...there,,can anyone debugging my code..

this program intend to find the average and count how many numbers is positif and negatif from 10 numbers entered by user.

My problem is when i run the program the result of average is correct but somehow on the result of negatif and positif numbers showed wrongly..

Can anyone tell me where's the error??

Thanks so much

```
#include <iostream>
void getNum(float& num,float& sum);
void avgNum (float sum,float& avg);
void countNum (float num,int& negatif,int& positif);
void printNum(float avg, int negatif, int positif);
using namespace std;
int main()
{
float n,s,a;
int neg,pos;
getNum(n,s);
avgNum(s,a);
countNum(n,neg,pos);
printNum(a,neg,pos);
system("pause");
return 0;
}
void getNum(float& num,float& sum)
{
cout<<"Please enter 10 numbers:"<<endl;
sum=0;
for(int i=0; i<10; i++)
{
cout<<"Enter "<<i+1<<" number:";
cin>>num;
sum=sum+num;
}
return;
}
void avgNum(float sum,float& avg)
{
avg=sum/10;
return;
}
void countNum(float num,int& negatif,int& positif)
{
if(num<0)
negatif++;
else
positif++;
return;
}
void printNum(float avg, int negatif, int positif)
{
cout<<"The average of the 10 numbers is:"<<avg<<endl;
cout<<"We have"<<negatif<<"negatif numbers"<<endl;
cout<<"We have"<<positif<<"positif numbers"<<endl;
return;
}
```

*Edited 7 Years Ago by Nick Evan*: removed extra [tex]-tags