Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- // prototypes
- void add(int* f,int h);
- void show(int* f,int h);
- int average(int* f,int h);
- int main()
- {
- // getting size of a array
- cout << "How many numbers would you insert? : ";
- int i = 0;
- cin >> i;
- cout << endl;
- // the dinamic array
- int* arr = new int[i];
- // call functions
- add(arr, i);
- show(arr, i);
- average(arr, i);
- // deleting the dinamic array
- delete[] arr;
- system("pause");
- return 0;
- }
- // declaring of the functions
- // this function should fill up the array
- void add(int* f1, int h)
- {
- for(int j = 0 ; j < h ; j++)
- {
- cout << "Insert " << j+1 << ". value : ";
- cin >> f1[j]; //this should be the problem
- cout << endl;
- }
- }
- // this function should show the array
- void show(int* f2, int h)
- {
- for(int j = 0 ; j < h ; j++)
- {
- cout << f2[j] << ", ";
- }
- }
- // this function should should show average value of the array
- int average(int* f3, int h)
- {
- int n = 0;
- for(int j = 0 ; j < h ; j++)
- {
- n += f3[j];
- }
- n /= h;
- return n;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement