#include <iostream>
#include <conio.h> //needed to allow getch()
#include <iomanip>
using namespace std;
int mean(const int [ ], int );//function prototype
int main() // initializing the main program
{
char ch1;
cout<<"Please enter the letter M for the mean function or the letter F for the Frequency function"<<endl;
cin>>ch1;
if(ch1 = 'M'||'m')
{
cout<<"The average of the array is:"<<avg<<endl;
getch();
return 0;
}
}
float mean()
{
int sum=0;
int avg=0;
int data[40] = {2, 3, 4, 5, 4, 6, 8 ,9, 3, 2,
7, 8, 7, 8, 9, 4, 5, 3, 6, 1,
3, 4, 5, 2, 7, 8, 9, 5, 8, 9,
4, 5, 6, 8, 9, 8, 7, 8, 9, 4};
for(int i = 0; i < 40; ++i)
sum+=data[i];
avg=sum/40;
}
How do i display the average found in float mean() in the main() function?