0
How to make a simple matrix using nested loops in c++.
Without arrays or using matrix command
6 Answers
+ 1
A nested loop is fairly straight forward, its how you plan to store and access the data that can be a little challenging.
You said âwithout arraysâ, have you considered using vectors?
+ 1
Then you donât have to store the values, which makes things much simpler.
Since this is a homework assignment I wonât give you the complete answer, but this will get you started:
for(int i = 0; i < 3; i++)
{
for(int j = 0; j < 3; j++)
{
cout << âsome numberâ;
}
cout << âsomething elseâ;
}
Play around with that a little and you will have the answer. đ
+ 1
Thank you soo much. I will try and complete my code soon. Once again thanks for giving your time and attention. đ
0
No I haven't tried with vectors. As I'm a beginner and I don't know how to use vectors.
0
In that case using vectors for a 2D matrix might be a bit advanced.
What are the other constraints / expectations if you cannot use arrays?
0
I was given an assignment in which it said that we have to use nested loops(for,while,do-while) and show the output of 123
456
789