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:
- As your first task, you will print a triangle whose border is made of * signs and the interior is #.
- Ask the user for n, the number of lines with # signs.
- If n is less than 1, display a warning and proceed to the second task.
- 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.
- As your second task, you will print an X sign which is made of * signs.
- Ask the user for m, the number of lines of the X sign.
- If m is less than 3, display a warning and skip this task.
- 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
Get step-by-step solutions from verified subject matter experts
