Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- void printArr(const int* begin, const int* const end)
- {
- while (begin != end)
- {
- std::cout << *begin++ << ' ';
- }
- std::cout << '\n';
- }
- void fillArr(int* begin, const int* const end, int val)
- {
- while (begin != end)
- {
- *begin++ = val;
- }
- }
- int globalArr[100];
- int main()
- {
- int num{ 442 };
- int* ptr{ nullptr };
- double* ptrD{ new double{36.6} };
- std::cout << "Temperature is: " << *ptrD << '\n';
- delete ptrD;
- ptr = new int{ 42 };
- std::cout << *ptr << '\n';
- *ptr += 3;
- std::cout << *ptr << '\n';
- *ptr = 33;
- std::cout << *ptr << '\n';
- delete ptr;
- int arrSize;
- std::cout << "Enter array size: ";
- std::cin >> arrSize;
- ptr = new int[arrSize] {};
- printArr(ptr, ptr + arrSize);
- delete[] ptr;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment