jamesrdaza

Untitled

Jul 29th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. bool add()
  8. {
  9. char again;
  10. cout << "Would you like to add more? (Y/N): ";
  11. cin >> again;
  12. if (again == 'Y')
  13. {
  14. return true;
  15. }
  16. else
  17. {
  18. return false;
  19. }
  20. }
  21.  
  22. double* ReadData(int& size)
  23. {
  24. double* arrPoint = new double[10];
  25. int count = 0;
  26. int input;
  27. char again;
  28.  
  29. cout << "Would you like to add more? (Y/N): ";
  30. cin >> again;
  31. if (again == 'Y')
  32. {
  33. cout << "Please enter the contents for the array (Enter 'q' to quit): ";
  34. while (cin >> input)
  35. {
  36. if (cin.fail())
  37. {
  38.  
  39. break;
  40. }
  41.  
  42. arrPoint[count] = input;
  43.  
  44. size++;
  45. count++;
  46.  
  47. }
  48. }
  49.  
  50.  
  51. return arrPoint;
  52. }
  53.  
  54.  
  55.  
  56. int main()
  57. {
  58.  
  59. double* pointer;
  60. int size = 0;
  61.  
  62.  
  63.  
  64. pointer = ReadData(size);
  65.  
  66.  
  67. cout << endl;
  68. for (int i = 0; i < size; i++)
  69. {
  70. cout << pointer[i] << " ";
  71. }
  72.  
  73. cout << endl;
  74. cout << size;
  75. system("pause");
  76. return 0;
  77. }
  78. vvvvvvvvvvvvvv
Advertisement
Add Comment
Please, Sign In to add comment