3 Level Nested for loop in C++ (C Plus Plus)
In this tutorial, we will learn the three-level nester for loop program in C++ (C Plus Plus).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#include<iostream> using namespace std; int main() { int outer, innermost, s; for(outer=5; outer>=1; outer--) { for(s=1; s<=5-outer; s++) cout<<" "; for (innermost=1; innermost<=outer; innermost++) { cout<<"*"; } cout<<endl; } } |
Output
