C++ new operator


SUBMITTED BY: RavishBhatt

DATE: June 29, 2016, 8:57 a.m.

FORMAT: C++

SIZE: 429 Bytes

HITS: 529

  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int n, *pointer, c;
  6. cout << "Input an integer\n";
  7. cin >> n;
  8. pointer = new int[n];
  9. cout << "Input " << n << " integers\n";
  10. for (c = 0; c < n; c++)
  11. cin >> pointer[c];
  12. cout << "Elements entered by you are\n";
  13. for (c = 0; c < n; c++)
  14. cout << pointer[c] << endl;
  15. delete[] pointer;
  16. return 0;
  17. }

comments powered by Disqus