Answer to Question #53183 in C++ for jemal

Question #53183
Define two functions which, respectively, input values for the elements of an array of real values and
output the array elements:
void ReadArray (double nums[], const int size);
void WriteArray (double nums[], const int size);
1
Expert's answer
2015-07-01T06:52:05-0400

Solution.
#include <iostream>

// The function prototypes
void ReadArray(double nums[], const int size);
void WriteArray(double nums[], const int size);

using namespace std;

void main()
{
const int size = 10;
double nums[size];

// Calling functions
ReadArray(nums, size);
WriteArray(nums, size);

// To pause
cin.get();
cin.get();

return;
}

void ReadArray(double nums[], const int size)
{
for (int i = 0; i < size; i++)
{
cout << "nums[" << i << "] = ";
cin >> nums[i];
}
}

void WriteArray(double nums[], const int size)
{
for (int i = 0; i < size; i++)
{
cout << nums[i] << '\n';
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS