Friday, 5 July 2013

Data Insertion in 2D Array + Demonstration that how that is stored in 2D Array

Features of Program:
                                   In following program it is taught that how we can insert data in 2D array, and how data is stored in 2D array .


#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int ar[5][2];

 for(int row=0;row<5;row++)
 {
   for(int col=0;col<2;col++)
   {
     cout<<"Enter The Number for row# "<<row+1<<" & Column# "<<col+1<<":";
     cin>>ar[row][col];
   }
 }
   for(int i=1;i<=15;i++)
   {

     for(int k=1;k<=11;k++)
     {
if(i==1||i==15)
{
cout<<"*";
}
else if(i%3==0)
{
cout<<"*";
}
else if(k==1||k==11||k==6)
{
cout<<"*";
}
else
{
cout<<" ";
}
     }
     cout<<endl;
   }


     int x=3,y=11;//,count=0;
     for(row=0;row<5;row++)
     {
       for(int col=0;col<2;col++)
       {
gotoxy(x,y);
cout<<ar[row][col];
x+=5;
       }
       y+=3;
       x=3;
     }
getch();
}

No comments:

Post a Comment