Solution to Write a program that takes a number n and outputs a point−down triangle of height … - Sikademy
Author Image

Archangel Macsika

Write a program that takes a number n and outputs a point−down triangle of height n and width 2n−1; the output for n = 6 would be: Enter a number: 6 *********** ********* ******* ***** *** *

The Answer to the Question
is below this banner.

Can't find a solution anywhere?

NEED A FAST ANSWER TO ANY QUESTION OR ASSIGNMENT?

Get the Answers Now!

You will get a detailed answer to your question or assignment in the shortest time possible.

Here's the Solution to this Question

Solution in Python Programming Language


height = int(input("Enter a number: "))
width = (2*height)-1
n = height
offset = 0
while (height > 0):
    print ' '*offset,"*"*width,"\n"
    height -= 1
    width = (2 * height) - 1
    offset = n - (height)

If you would like to see a different solution or an implementation in a different programming language Kindly let us know



Related Answers

Was this answer helpful?

Join our Community to stay in the know

Get updates for similar and other helpful Answers

Question ID: mtid-3-stid-9-sqid-6-qpid-6