Hi all i want to print


In pyramid form

please help..

jwenting commented: sigh... -3

Recommended Answers

All 5 Replies


We can't do your homework, you will learn nothing.
But, some hints may help you ;

  1. It's evident that you need to use a loop inside another one :
    The first loop is to create many lines,
    The second one is to print many stars or dots.

  2. The second loop uses the first loop's index : the number of dots or stars per line is the number of the line itself (the first loop index).

  3. "Alternative" means "boolean" : use a boolean to change between dots and stars, the boolean changes its value in the end of the first loop.

Good Luck.

You will want:

  • a variable that holds the character currently being printed
  • an outer for() loop to count the number of lines to print
  • an if() statement that flips the character being printed (hint: use the modulo (%) operator)
  • two inner for() loops, one that prints spaces, the second that prints the character line.
  • The total of the spaces and characters should be the same for each line, but on each successive line, you should add one to the number of characters and hence subtract one from for number of spaces.

Please write the whole program i have to submit my assignment tomorrow please its urgent
.wil be higly grateful.

commented: you won't be grateful, you'll just be a lazy cheat, and you won't learn a thing. -3
commented: sigh... +0


The rule at DaniWeb are simple:

Do provide evidence of having done some work yourself if posting questions from school or work assignments

We can provide assistance, but we cannot do the work for you. You must solve the problem, if you are to learn from it. Otherwise, you are cheating, something we cannot condone, and even if we did, you would be likely to get caught. Do the work yourself; we've given you more than enough information to solve the problem.

and where's the urgency?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.