user2552
9
Q:

how to iterate through array in c++

string texts[] = {"Apple", "Banana", "Orange"};
for( unsigned int a = 0; a < sizeof(texts); a = a + 1 )
{
    cout << "value of a: " << texts[a] << endl;
}
1
for(int i = 0; i < 4; i++) {
  cout << cars[i] << "\n";
}
2
for(int i=0; i<n; i++)
  cout<<array[i]<<" "
  cout<<endl;
0

New to Communities?

Join the community