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>
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;
}
Comments
Leave a comment