0

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();
}

Edited by suraj_p: to add a missing statement

3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by suraj_p
Featured Replies
  • 1
    vmanes 1,165   5 Years Ago

    [code] 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 [/code] 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? Read More

0

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

Edited by Clinton Portis: n/a

0

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

1
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?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.