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);

Expert's answer

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';

}

}

## Comments

## Leave a comment