Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions