A program to initialize a 2-D array of size 1*10 (i.e. a single column). Store numbers 1 to 10 in the column and display it.

 

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[1][10],i,j;

for(i=0;i<1;i++)
for(j=0;j<10;j++)
a[i][j]=j+1;

for(i=0;i<1;i++)
for(j=0;j<10;j++)
cout<<a[i][j]<<"\n";

getch();
}

 

< Back