Creating a triangle pattern in C++?

Im trying to create a pattern that looks like this: _____* ____*** ___***** __******* Its the 1,3,5,7 triangle pattern, can someone correct my code to do this: #include <iostream> using namespace std; // -------------------------------- // ----- ENTER YOUR CODE HERE ----- //... show more Im trying to create a pattern that looks like this:

_____*
____***
___*****
__*******

Its the 1,3,5,7 triangle pattern, can someone correct my code to do this:

#include <iostream>
using namespace std;


// --------------------------------
// ----- ENTER YOUR CODE HERE -----
// --------------------------------
int main ()
{
printStars(f, g, h);
return 0;
}

int printStars (int f,int g,int h)
{
int f, g, h;

for (f=1; f<=7; f++)
{
for (h= 5; h >=0; h--)
{
cout<<" ";
while (g=0)
{
for (g=1; g<=lines; g++)
}

{
cout<<"* ";
}

}
cout<<endl;
}}

// --------------------------------
// --------- END USER CODE --------
// --------------------------------
Update: I tried you method Sandeep K, but i the stars format to be 1,3,5,7
2 answers