C++ program to create a 2D array

This Program will take entry of array row wise and column wise and will generate a two dimensional array like for example you have been asked to create a C++ program that could take in names of 10 cities each of at least 50 letters so who will you do at this time itself you have to go for a 2-D array. The program for 2-D array creation is as follows:

#include<iostream.h>
#include<conio.h>
void twodigit(int str[10][10],int a,int b)
{
int i,j,flag=0;
cout<<"The Two digit Numbers are: ";
for(i=0;i<a;i++)
for(j=0;j<b;j++)
{
if(str[i][j]>=10&&str[i][j]<=99)
{
cout<<str[i][j]<<ends;
flag=1;
}

}
if(flag==0)
cout<<"None";
}
void main()
{
clrscr();
int str[10][10],i,j,a,b;
cout<<"\n EnterNo. of rows: ";
cin>>a;
cout<<"\nEnter the no. of columns: ";
cin>>b;
cout<<"\nEnter the Elements of the array: ";
for(i=0;i<a;i++)
for(j=0;j<b;j++)
cin>>str[i][j];
twodigit(a,a,b);
getch();
}

Share this

Related Posts

Previous
« Prev Post