NESTED LOOPS IN C++
- Get link
- X
- Other Apps
IN THIS BLOG I WILL SHOW YOU HOW TO MAKE PATTERNS USING FORLOOPS AND ALSO WE WILL SHOW YOU SYNTAX OF NESTED FOR LOOPS
Here are codes with different types of shapes:
//nested for loops in c++
//lets begin
#include<iostream>
using namespace std;
int main()
{
for (int i = 1; i <= 5; i++)
{
for (int j = 1; j <= i; j++)
{
cout << j;
}cout << endl;
}
}
output:
#include<iostream>
using namespace std;
int main()
{
for (int
i = 5; i >= 1; i--)
{
for
(int j = 1; j <= i; j++)
{
cout
<< j;
}cout
<< endl;
}
}
OUTPUT:
//nested for loops in c++
//lets begin
#include<iostream>
using namespace std;
int main()
{
for (int i = 1; i <= 5; i++)
{
for (int j = 1; j <= i; j++)
{
cout << (i-j)+1;
}cout << endl;
}
}
output:
FOR MORE INFORMATION PLS VISIT:
MY YOUTUBE CHANNEL
- Get link
- X
- Other Apps
Comments
Post a Comment