help me work with for(;;)

hello ;
I write this program but it's have some error please help me to work it and Tell me what the problem! (sum of matrix 2*2)


#include <iostream>
#include <conio.h>
using namespace std;
void main(){
int a[2][2],b[2][2],c[2][2];
int i,j;
for(i=0;i<2;i++){
for(j=0;j<2;j++)
{
cout<<"Please Enter a Number : ";
cin>>a[2][2];
}
}
cout<<"Please Enter 2th Number : ";
cin>>b[2][2];
for(i=0;i<2;i++){
for(j=0;j<2;j++)
c[i][j]=a[i][j]+b[i][j];
}
for(i=0;i<2;i++){
for(j=0;j<2;j++)

{
cout<<c[i][j]<<'\t';
}
cout<<endl;



}
What is this
cout<<"Please Enter a Number : ";
cin>>a[2][2];


it should be
cin>>a[i][j];


and
cin >>b[2][2]

it's wrong
you have to take b[i][j] by using 2 for loop again.
not that its related to your error, but you should use int main, not void, as main always returns an int to the parent program, e.g OS
Topic archived. No new replies allowed.