Nested For Loop including 3 loops in C++ (C Plus Plus)

Nested For Loop including 3 loops in C++ (C Plus Plus)

In this tutorial, we will learn the nested for loop program including three loops in C++ (C Plus Plus).

#include<iostream>
using namespace std;
int main()
{
	int outer, innermost, s;
	for(outer=1; outer<=5; outer++)
	{
	for(s=1; s<=5-outer; s++)	
	cout<<" ";
	for (innermost=1; innermost<=outer; innermost++)
	{
	
	cout<<"*";
	}
	cout<<endl;
}
	}

Output

Nested For Loop including 3 loops in C++ (C Plus Plus)
Nested For Loop including 3 loops in C++ (C Plus Plus)

 

Prof.Fazal Rehman Shamil (Available for Professional Discussions)
1. Message on Facebook page for discussions,
2. Video lectures on Youtube
3. Email is only for Advertisement/business enquiries.