Write down piece of code that will declare a matrix of 3x3 And-02379
This subjective question is related to the book/course vu mth718 Topics in Numerical Methods. It can also be found in vu mth718 Mid Term Solved Past Paper No. 10.
Question 1: Write down piece of code that will declare a matrix of 3x3. And initialize all its locations with 0;
include<iostream.h>
main () {
int matrix [3][3];
int inivalue = 0;
for (int a=0;a<3;a++)
{ for (int b = 0;b<3;b++)
{ matrix[a][b]= inivalue;
cout<<matrix[a][b]<<endl;}}
}
Page. No. 4/15
Answer:
int matrix [3] [3] ;include<iostream.h>
main () {
int matrix [3][3];
int inivalue = 0;
for (int a=0;a<3;a++)
{ for (int b = 0;b<3;b++)
{ matrix[a][b]= inivalue;
cout<<matrix[a][b]<<endl;}}
}
Page. No. 4/15