Guest User

Untitled

a guest
Jan 13th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4.  
  5. using namespace std;
  6.  
  7.  
  8.  
  9. typedef int *numbers;
  10.  
  11.  
  12.  
  13. void assign(int arg[], int &argl);
  14.  
  15. void print(int arg[], int &argl);
  16.  
  17.  
  18.  
  19.  
  20.  
  21. int main()
  22.  
  23. {
  24.  
  25. numbers nums;
  26.  
  27. int length;
  28.  
  29.  
  30.  
  31. cout << "Enter the size of the array: ";
  32.  
  33. cin >> length;
  34.  
  35.  
  36.  
  37. nums = new int[length];
  38.  
  39.  
  40.  
  41. assign(nums, length);
  42.  
  43. print(nums, length);
  44.  
  45. return 0;
  46.  
  47. }
  48.  
  49.  
  50.  
  51. void assign(int arg[], int &argl)
  52.  
  53. {
  54.  
  55. for (int i = 0; i < argl; i++)
  56.  
  57. {
  58.  
  59. cout << "myArray[" << i << "] = ";
  60.  
  61. cin >> arg[i];
  62.  
  63. }
  64.  
  65. }
  66.  
  67.  
  68.  
  69. void print(int arg[], int &argl)
  70.  
  71. {
  72.  
  73. cout << "myArray = {";
  74.  
  75. for ( int i = 0; i < argl - 1; i++)
  76.  
  77. {
  78.  
  79. cout << arg[i] << ", ";
  80.  
  81. }
  82.  
  83. cout << arg[argl-1] << "}" << endl;
  84.  
  85. }
Add Comment
Please, Sign In to add comment