When i run this program it takes more values and prints less values....
this runs on Dev C++(www.bloodshed.net)

#include<iostream>
using namespace std;
#include<conio.h>
int main()
{
    int arr[5][5],i,j,k,l;
    cout<<"Enter matrix row wise";
    for(i=0;i<=3;i++)
    {
         for(j=0;j<3;j++)
         { 
             cin>>arr[i][j];                
         }
    
     }

      for(k=0;k<3;k++)
      {   
          for(l=0;l<3;l++)
          {   
              cout<<" "<<arr[k][l];
          } 
          printf("\n");
          
      }
getch();
}

So what are ye' trying to do with this code? (why doesn't it work the way you think it should)

Actually i am a newbie to c++
i have been trying to initialise a matrix using 2D array.
when i input members row wise then it takes 3 numbers more and displays all numbers excluding last three...
i want to input a matrix and output the same matrix in Matrix form

for(i=0;[B]i<=3[/B];i++)
{
  for(j=0;[B]j<3[/B];j++)
  {
   //input
  }
 
}
 
for(k=0;[B]k<3[/B];k++)
{
  for(l=0;[B]l<3[/B];l++)
     //output

Look at the difference between the loop test in your input and output sections? Shouldn't they be the same? Or at least use the same relational op?

Thank you very much......
i was going mad on this code

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.