Question: Write a program that prints a right-angled triangle and a X sign as follows: As your first task, you will print a triangle whose border

Write a program that prints a right-angled triangle and a X sign as follows:

  1. As your first task, you will print a triangle whose border is made of * signs and the interior is #.
    1. Ask the user for n, the number of lines with # signs.
    2. If n is less than 1, display a warning and proceed to the second task.
    3. If not, print the right angled triangle with n lines of #. On each new line there should be one more # than the previous line. Note that the complete shape will have n+3 lines. See the sample output.
  2. As your second task, you will print an X sign which is made of * signs.
    1. Ask the user for m, the number of lines of the X sign.
    2. If m is less than 3, display a warning and skip this task.
    3. If not, print the huge X sign made up of * characters. See the sample output.

Enter n: 5

*

**

*#*

*##*

*###*

*####*

*#####*

********

Enter m: 7

*

*

* *

* *

*

* *

* *

* *

Sample screen output 1:

Enter n: 0

Invalid input. Enter m: 8

*

*

* *

* *

**

**

* *

* *

* *

Sample screen output 2:

Enter n: 10

*

**

*#*

*##*

*###*

*####*

*#####*

*######*

*#######*

*########*

*#########*

*##########*

************* Enter m: 2

Invalid input.

Sample screen output 3:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!