What's wrong with this? I thought the code doesn't have any problem but it just doesn't output what I want.
Code:
#include <iostream>
using namespace std;
void main()
{
int a = 0, b = 0,size;
int array[10][10];
cin>>size;
for(; a < size; a++)
{
for(; b < size; b++)
{
cin>>array[a][b];//input entries
if ((b+1)%size==0)
cout<<endl;//end the line when a row is complete
}
}
for(; a < size; a++)
{
for(; b < size; b++)
{
cout<<array[a][b];//output entries in a row
if ((b+1)%size==0)
cout<<endl;//end the line when a row is complete
}
}
}
If the size input is 2,then this is what I expected on the screen when input:
And expected output:
This is what I actually got:
And there is no output.
Plz help.