Answer to Question #202424 in C++ for Jordaine Myrie

Question #202424

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-05T07:11:34-0400
#include <iostream>
using namespace std;
void getTemp(float *arr, int size){
    for(int i = 0; i < size; i++) cin>>arr[i];
}
int main(){
    int size; 
    float arr[10];
    cout<<"Input size of array: "; cin>>size;
    if(size > 10) size = 10;
    cout<<"Input array elements: "; getTemp(arr, size);
    for(int i = 0; i < size; i++) cout<<arr[i]<<" ";
    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