0

Write a program that uses a dynamic array that contains 5 items of double values. The size of the array is entered when the program is run. Aldo the 5 values must be entered. These tasks are done in the main ( ) function. Then write a function to display the 5 values. The function must have a pointer variable as a parameter. The function is called from the main ( ).

28th Sep 2016, 4:39 PM
Shannon Hostetler
Shannon Hostetler - avatar
2 Respuestas
+ 1
#include<iostream> using namespace std; void print(double* e, int size) { if(e == nullptr) return; for(int i=0;i<size;i++) cout<<*e[i] ; } int main() { double* arr; int size; cout<<"insert size"; cin>>size; arr = new double[size] ; for(int i=0;i<size;i++) {cout<<"insert val"; cin>>*arr[i] ; } print(arr, size) ; delete[] arr ; return 0; } This should be good enough.
28th Sep 2016, 9:36 PM
Riccardo
Riccardo - avatar
+ 1
Are you cheating for a class assignment?
15th Oct 2016, 2:30 PM
Sannabasavana haraginadoni
Sannabasavana haraginadoni - avatar