daily pastebin goal
24%
SHARE
TWEET

Untitled

a guest Feb 20th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. void memAlloc(double *arr, int size) {
  7.     arr = new double[size];
  8. }
  9.  
  10. void fillArr(double *arr, int size) {
  11.     for (int i = 0; i < size; i++) {
  12.         cout << "arr[" << i << "] = ";
  13.         cin >> arr[i];
  14.     }
  15.     cout << endl;
  16. }
  17.  
  18. void showData(double *arr, int size) {
  19.     for (int i = 0; i < size; i++) {
  20.         cout << "arr[" << i << "] = " << arr[i] << endl;
  21.     }
  22. }
  23.  
  24. void freeMemory(double *arr) {
  25.     delete[] arr;
  26. }
  27.  
  28. int main()
  29. {
  30. main:
  31.     string usrInp;
  32.     double *arr;
  33.     int size;
  34.     cout << "Enter array size: \n";
  35.     cin >> size;
  36.     //arr = new double[size];
  37.  
  38.     memAlloc(arr, size);
  39.     for (int i = 0; i < size; i++) {
  40.         cout << "arr[" << i << "] = " << arr[i] << endl;
  41.     }
  42.     fillArr(arr, size);
  43.     showData(arr, size);
  44.     freeMemory(arr);
  45.  
  46.     cout << "Continue?" << endl;
  47.     cout << "yes or no" << endl;
  48.     cin >> usrInp;
  49.  
  50.     if (usrInp == "yes"){
  51.         goto main;
  52.     }
  53.     else if (usrInp == "no" || usrInp != "yes") {
  54.         exit(1);
  55.     }
  56.        
  57.  
  58. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top