i am getting result of average in int instead of float, tell me where i have made mistake. this is the code.
#include<iostream>
using namespace std;
void getData (int a[], int s);
int numbersSum (int a[], int s);
float average (int sum, int size);
int main()
{
int size=0;
int a[size];
cout<<"how many numbers: "<<endl;
cin>>size;
cout<<"Enter "<<size<<" numbers:"<<endl;
getData (a, size);
int sum=0;
sum=numbersSum (a, size);
cout<<"sum of these "<<size<<" numbers is "<<sum<<endl;
float avg=0;
avg=average (sum, size);
cout<<"the average of these "<<size<<" numbers is "<<avg<<endl;
return 0;
}
void getData(int a[], int s)
{
for (int i=0;i<s;i++)
{
cin>>a[i];
}
}
int numbersSum (int a[], int s)
{
int sum=0;
for (int i=0;i<s;i++)
sum=sum+a[i];
return sum;
}
float average (int sum, int size)
{
float a=sum/size;
return a;
}