I need like this...Please guide me how to make it.
*
* *
* *
* *
* * * * *
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Nilesh JadavRank #109 · 20.3K reputationPosted Aug 25, 2015, 5:39 AM EDT
int main()
// endl is for new line
{
cout<<"\"Hollow Triangle Shape\"\n\n";
int z=1;
for (int i=0; i<7; i++)
{
for (int j=7; j>i; j--)
{
cout<<" "; // displaying space here
}
cout<<"*"; // displaying asterisk here
if (i!=0)
{
for (int k=1; k<=z; k++)
{
cout<<" ";
}
cout<<"*";
z+=2;
}
cout<
}
for (int i=0; i<=z+1; i++)
{
cout<<"*";
}
return 0;
}
intmain() {//Declaring the variables.introws, position;//Prompts user to enter number of rows.printf("Enter the number of rows in the triangle: ");scanf("%d", &rows);//Prints the first row of the triangle.for(position = 1; position <= rows-1; position++)printf(" ");printf("*\n");//Prints the middle part of the triangle.//Prints the last row of the triangle.for(position = 1; position <= rows*2-1; position++)printf("*");return0;Vikram10 reputationPosted Aug 25, 2015, 10:04 PM EDT
Nilesh JadavRank #109 · 20.3K reputationPosted Aug 25, 2015, 10:22 PM EDT