Nested loops
A nested loop is one loop inside another loop.
void main()
{ int width;
cout << "enter the width of the square: ";
cin >> width;
for(int i = 0; i < width; i++) {
for( int j = 0; j < width; j++){
cout << "* " ;
}
cout << endl;;
}
}
Previous slide
Next slide
Back to first slide
View graphic version