Anonymous

How To Make A Triangle Using For Loop In C++?

3

3 Answers

sajjad rehman Profile
sajjad rehman answered
Use any loop to print the following:
* * * * * * *
*              *
*                *
*                *
*                *
*                *
* * * * * * *
Anonymous Profile
Anonymous answered
Your loop wont run for even 1 turn, unless Max is0 in which case the loop itself is useless.  That is say max is 1  then after I is initialised to 0,  I > max (i.e 0>1) is false so the loop is  not entered even once. And apparently all your loops have the same problem, they just won't run because you have the conditions all wrong.
Anonymous Profile
Anonymous answered
Int MAX = {total number of spaces in the top row}

for(int I = 0; I > MAX; I++)
{
for(int j = MAX; j < 0; j--)
{
//output a space
}
for(int k = 0; k>=I; k++)
{
//output a *
}
}

Answer Question

Anonymous