C++ One Dimensional Array Program

« Previous Program Next Program »

One Dimensional Array Program in C++

To print one dimensional array in C++ programming, you have to ask to the user to enter array size and array elements to store all the array elements in one dimensional and then print the array in one dimension using one for loop as shown here in the following program.

C++ Programming Code for One Dimensional (1D) Array

Following C++ program ask to the user to enter the array size, then ask to enter the element of the array to store the elements in the array, then finally display the array element on the screen:

/* C++ Program - One Dimensional Array Program */
void main()
	int arr[50], n;
	cout<<"How many element you want to store in the array ? ";
	cout<<"Enter "<<n<<" element to store in the array : ";
	for(int i=0; i<n; i++)
	cout<<"The Elements in the Array is : \n";
	for(i=0; i<n; i++)
		cout<<arr[i]<<" ";

When the above C++ program is compile and executed, it will produce the following result:

C++ program one dimensional array

Same Program in Other Language

You may like the same program in other programming languages:

« Previous Program Next Program »


Quick Links
Signup - Login - Give Online Test