how to use array without size in c 2b 2b

Solutions on MaxInterview for how to use array without size in c 2b 2b by the best coders in the world

showing results for - "how to use array without size in c 2b 2b"
Morris
18 Nov 2018
1#include <iostream>
2
3int main()
4{
5	//Create a user input size
6	int size;
7	std::cout << "Enter Size Of Array : ";
8	std::cin >> size;
9
10	//Create the array with the size the user input
11	int *myArray = new int[size];
12
13	//Populate the array with whatever you like..
14	for(int i = 0; i < size; ++i)
15	{
16		myArray[i] = rand() % 10;
17	}
18
19	//Display whats in the array...
20	for(int i = 0; i < size; ++i)
21	{
22		std::cout << "Item In Element " << i << " of the array = : " << myArray[i] << std::endl;
23	}
24
25	//Delete the array
26	delete[] myArray;
27
28	return 0;
29}