Answer to Question #202427 in C++ for Master j

Question #202427

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. 


1
Expert's answer
2021-06-02T16:36:30-0400
#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;
}

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
New on Blog