Questions:
Write C++ Program to draw inverted hollow triangle
Explanation:
This problem is simple and just demonstration of nested loop. Below mention code is compiled in Visual Studio 2015 and output snap is attached.. If any problem you feel and want explanation feel free to contact.
Code:
Output:
Related Articles:
Write C++ Program to draw inverted hollow triangle
Explanation:
This problem is simple and just demonstration of nested loop. Below mention code is compiled in Visual Studio 2015 and output snap is attached.. If any problem you feel and want explanation feel free to contact.
Code:
/**************************************************|
/*************C++ Programs And Projects************|
***************************************************/
#include<iostream>
using namespace std;
void main()
{
int w = 6;
for (int g = 0; g<9; g++)
{
cout
<< "*"; // Displaying asterisk here
}
cout
<< endl; // endl is for new line
for (int a = 1; a <= 3; a++)
{
for (int b = 0; b<a; b++)
{
cout
<< " "; // displaying space here
}
cout
<< "*";
for (int c = 1; c<w; c++)
{
cout
<< " ";
}
cout
<< "*" << endl;
w
= w - 2;
}
for (int e = 1; e <= 1; e++)
{
for (int f = 4; f >= e; f--)
{
cout
<< " ";
}
cout
<< "*";
}
cout
<< endl;
}
Output:
Related Articles:
0 Questions:
Post a Comment