How to make diamond with the help of loops

Recommended Answers

All 2 Replies

Loops do repetitive things. Loops also count with each iteration.

When you think of a diamond written in ASCII asterisks, you can think it starts off with one asterisk on line 1, then 2, then 3, then 4 … each line is indented by one character less … then eventually it does the opposite.

commented: Please tell me the program of it? +0

That's not how this works. Show us what you have tried so far and we can help. For starters, try a specific case first - say a diamond of width five. That will require nine lines of output. Write the code to generate that without a loop (one line of code for each line of output). Then look at that code for a pattern that would tell you how to replace it with a loop.

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.