(C++) please explain the steps and you don't have to solve the whole thing just a great starting point and hints!
Write a function called read floats(int n) that reads n float values from the user into an array and return the array back to the caller. Recall that a regular array will get deallocated when the function returns
#include <iostream> using namespace std; float* floats(int n){ float* arr = new float(n); for(int i = 0;i<n;i++){ cout<<"Enter float value: "; cin>>arr[i]; } return arr; } int main() { float* arr = floats(5); for(int i = 0;i<5;i++){ cout<<arr[i]<<endl; } return 0; }
Get Answers For Free
Most questions answered within 1 hours.