Question: Write a C ++ program that declares an array alpha of 50 components of the type double. Initialize the array so that the first 25

Write a C++ program that declares an array alpha of 50 components of the type double.

Initialize the array so that the first 25 components are equal to the square of the index variable, and the last 25 components are equal to three times the index variable.

Output the array so that 10 elements per line are printed.

Use functions to process data.

Make sure it is neat.

Here is the code I have thus far. I'm having trouble with sending arrays to functions and keeping up with the requirements (I am aware that the variable x should be alpha instead).

Any help is much appreciated.

#include "stdafx.h" #include using namespace std;

const int limit = 25;

//Declare a function to process and output void output(double x[limit][limit]) { //Declare the loop outputs here for easy editing int i = 0, j = 0, index = 7; //Create a for loop to display the multiplication multiple times for (i = 0; i <= 26; ++i) { //If statement to process a new line for 10 and 21 if (i == 10 || i == 21) { //Output to a new line cout << " "; } else { //Output the array x[i][0] = i*index*index; cout << x[i][0] << "\t"; } } //Create another for loop to display the multiplication multiple times for (j = 0; j <= 26; ++j) { //If statement to process a new line every 10ish if (j == 5 || j == 16 || j == 27) { //Output to a new line cout << " "; } else { //Output the array x[0][j] = j*index*index*index; cout << x[0][j] << "\t"; } } }

int main() { //Declare an array double x[limit][limit]; cout << " \t\t\t Lab14 \t\t\t By David Botsolis " << endl; //Send the array to the function output output(x[limit][limit]); //Ask the user to press a key which ends the program cout << " \t\t\t\t\t\tPress any key to continue . . ."; system("pause>nul"); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!