Logo 
Search:

OOPs Concept Forum

Ask Question   UnAnswered
Home » Forum » OOPs Concept       RSS Feeds

read a matrix of size 5x5,

  Asked By: Fiqah    Date: Mar 26    Category: OOPs Concept    Views: 2031
  

some part in the code had error:-
help me..
#include <iostream.h>
class Matrix {
intnum[5][5];
public:
voidreadValues ();
voidshowValues();
};
void Matrix::readValues(){
cout<< "Insert 5 x 5 matrix : " <<endl;
for(int i = 0; i < 5; i++){
for(int j = 0; j < 5; j++){
cin>>num[i][j];
}
}
}
void Matrix::showValues(){
cout<< "Matrix contains : " <<endl;
for(int i = 0; i < 5; i++){
for(int j = 0; j < 5; j++){
cout<<num[i][j] << " ";
}cout<<endl;
}
}
int main()
{
Matrix matrix;
matrix.readValues();
matrix.showValues();
return 0;
}

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Ana Waninie     Answered On: Mar 27

#include <iostream.h>

class Matrix
{
int num[5][5];
public:
void readValues ();
void showValues();
};

void Matrix::readValues()
{
cout<< "Insert 5 x 5 matrix : \n" <<endl;
for(int i = 0; i < 5; i++)
{
for(int j = 0; j < 5; j++)
{
cin>>num[i][j];
}
}
}

void Matrix::showValues()
{
cout<< "\nMatrix contains : \n" <<endl;
for(int i = 0; i < 5; i++)
{
for(int j = 0; j < 5; j++)
{
cout<<num[i][j] << " ";
}
cout<<endl;
}
}

int main()
{
Matrix matrix;
matrix.readValues();
matrix.showValues();

char wait;
cin >> wait;
return 0;
}

 
Didn't find what you were looking for? Find more on read a matrix of size 5x5, Or get search suggestion and latest updates.




Tagged: