Question
This program is not working properly can't enter the second number instead of that enter number(y/n): just make this program run. #include using namespace std;
This program is not working properly can't enter the second number instead of that "enter number(y/n)":
just make this program run.
#include
using namespace std;
// function declaration:
double Average(int *arr,int size);
int main ()
{
int n;
char ch;
double avg;
cout<<"Enter The Size Of Array ";
cin>>n;
int average[n];
cout<<" Enter The Array Elements ";
int i=0;
do
{
cin>>average[i];
i++;
cout<<"Enter number:(y/n):";
cin>>ch;
}
while(ch == 'y');
cout << " Average Value of An Array Is: " << Average(average , n)<< endl;
return 0;
}
double Average(int *arr, int size)
{
int i, sum = 0;
double avg;
for (i = 0; i < size; ++i)
{
sum += arr[i];
}
avg = double(sum) / size;
return avg;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started