Hi..can anyone help me..debugging my codes..
when i compile and run it.. i dont get the accurate result..of sum and avg..can anyone help me telling where is the error??
thanks so much....
Here are the codes:
#include <iostream>
void getNum(int& num,int& sum);
void doProcess(int num, int& sum, float& avg);
void printNum(int sum, float avg);
using namespace std;
int main ()
{
int num,sum;
float avg;
getNum(num,sum);
doProcess(num,sum,avg);
printNum(sum,avg);
}
void getNum(int& num,int& sum)
{
cout<<"Please enter 5 numbers:"<<endl;
for(int i=0, sum=0; i<=4; i++)
{
cin>>num;
sum=sum+num;
}
return;
}
void doProcess(int num, int& sum, float& avg)
{
avg=sum/5;
return;
}
void printNum(int sum, float avg)
{
cout<<"The total is:"<<sum<<endl;
cout<<"The average is:"<<avg<<endl;
return;
}