+ 4
How to loop through an array and print its elements in C++?
I have a problem... How to make this code work? #include <iostream> using namespace std; int main() { int arr[3] = {0,1,0}; .......} And then what to write after that? //Thanks
3 Answers
+ 3
int arr[3] = {0,1,0};
for(int i = 0; i < 3; i++)
{
cout << arr[i];
}
You're kidding about this or what :)
+ 2
Ipang, do you also know how to loop through 2d arrays?
+ 1
@Reuben I'm learning about that too, here's what I did just minutes ago, there's a weird thing though, there's a line that doesn't get executed in the end before return, idk why or what. Maybe you can check if that line works??
https://code.sololearn.com/csYNBi1m9jVx/?ref=app