How to can write a C++ program that will print the following shapes. A. * *** ***** ******* ********* B. * *** ***** *** *
The Answer to the Question
is below this banner.
Can't find a solution anywhere?
NEED A FAST ANSWER TO ANY QUESTION OR ASSIGNMENT?
Get the Answers Now!You will get a detailed answer to your question or assignment in the shortest time possible.
Here's the Solution to this Question
#include<iostream>
using namespace std;
int main()
{
cout<<"Shape A:\n";
for(int i=1;i<=5;i++)
{
for(int j=1;j<=2*i-1;j++)
{
cout<<"*";
}
cout<<endl<<endl;
}
cout<<"Shape B:\n";
for(int i=1;i<=5;i++)
{
if(i<=3)
{
for(int j=1;j<=2*i-1;j++)
{
cout<<"*";
}
}
else if(i==4)
{
for(int j=1;j<=3;j++)
{
cout<<"*";
}
}
else
{
cout<<"*";
}
cout<<endl<<endl;
}
}