0
How to make a simple matrix using nested loops in c++.
Without arrays or using matrix command
6 ответов
+ 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