project help!

how to make shape like this? (using "while")

    *     *
   **    **
  ***   ***
 ****  ****
***** *****

very please, i need help immediately...

i can make only one triangle(using "for"), but now i'm gonna make two triangles using "while"....
and this is my triangle(using "for"),, but this is only one shape

#include <iostream.h>
#include <conio.h>

void main()
int n,i;
cout<<"enter digit :";
for(int i=0;i<n;i++)
for(int j=n;j>i;j--)
cout<<" ";
for(int k=0;k<i;k++)
cout<<" *";



so i need your help to make 2 shape

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

5 Years
Discussion Span
Last Post by snorky

Please use the [ CODE ] icon-button at the top of the editor to format both your code and your triangles, so we can better see what it is you're doing so far, and what you're trying to accomplish.

As far as making 2 triangles at once, think about what has to happen on each line, since you clearly can't back up (without using a much more advanced SDK like "curses").

And as far as using while() rather than for(), can you modify your existing code to make a single triangle using while() loops instead of for() loops? They are completely interchangeable. Since the for() loop syntax is effectively: for ( initialization ; test ; adjustment ) { do stuff; } where would you put each of those four italicized pieces relative to a while() loop?


i'm new here, sorry for my mistake,
so, can you make it for me?please...


Nope, we don't "make it for you" here on DaniWeb. You don't learn anything that way, and the point is to help you learn to be a programmer. I know you're new here, and thanks for the apology, but try it yourself. How many spaces do you need to start with? Then how many '*' do you need to print? Then how many more spaces? Etc.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.