Write a function, called getTemp, that accepts a one-dimensional floating-point array and an integer value representing the size of the array, within the function’s parameter; the function does not return a value. The function must demonstrate the use of required C++ programming instructions to store TEN (10) values in the function’s array. Your solution is also required use the for-loop to solve the given problem.
#include <iostream>
#include <time.h>
using namespace std;
void getTemp(float* integers, int arraySize)
{
for(int i = 0; i < arraySize; i++)
integers[i] = rand()%arraySize + 1;
for(int i = 0; i < arraySize; i++)
cout << integers[i] << " ";
}
int main()
{
srand(time(NULL));
cout << "Enter size of array: ";
int arraySize;
cin >> arraySize;
float* integers = new float[arraySize];
getTemp(integers, arraySize);
delete[] integers;
return 0;
}
Comments
Leave a comment