Question
ONLY ANSWER the SECOND QUESTION (1B) PLEASE, THE FIRST IS INCLUDED JUST TO PROVIDE CONTEXT!!!!! Question 1a: One-dimensional Array Write a program. Below is a
ONLY ANSWER the SECOND QUESTION (1B) PLEASE, THE FIRST IS INCLUDED JUST TO PROVIDE CONTEXT!!!!!
Question 1a: One-dimensional Array
Write a program. Below is a skeleton for the code to be written. There are three for loops: the first one is to set up the values for each array element by using the formula x[i]=i (i= 0, 99), and the second loop is to compute the sum of all array elements. The third for loop is used to calculate the standard deviation:
#include
using namespace std;
int main()
{
float x[100];
float sum=0, mean=0.0, standard_deviation=0.0;
//the first for loop to set up each array element by using the above formula
/* TO BE FILLED IN */
//the second for loop to compute the mean of all array elements and store it in mean
/* TO BE FILLED IN */
cout << Sum of all array elements is << sum << endl ;
//the third for loop to compute the standard deviation of all array elements and store it in standard_deviation
/* TO BE FILLED IN */
cout << Standard Deviation of all array elements is << standard_deviation << endl ;
system( pause);
return 0;
}
Question 1b: Passing an Array into a Function
Continue the work in Q1a and create a function with the following interface:
float SumArray(arg1, arg2), where arg1 is the whole array and arg2 represents the number of elements in the array. The purpose of this array is to compute the sum of all array elements.
Write a main( ) to test this function with the same data as in Q1.
cout << SumArray( x, 99) << endl;
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