Programming Nested Loop Questions on Shapes
1. Write a program to print a right-angled triangle using stars (*).
**
***
****
2. Write a program to print an inverted right-angled triangle using stars (*).
****
***
**
3. Write a program to print a pyramid using stars (*).
***
*****
*******
4. Write a program to print an inverted pyramid using stars (*).
*******
*****
***
5. Write a program to print a diamond shape using stars (*).
***
*****
*******
*****
***
6. Write a program to print a half pyramid using numbers.
12
123
1234
7. Write a program to print an inverted half pyramid using numbers.
1234
123
12
8. Write a program to print a full pyramid of numbers.
121
12321
1234321
9. Write a program to print an inverted number pyramid.
1234321
12321
121
10. Write a program to print a hollow square using stars (*).
*****
* *
* *
* *
*****
11. Write a program to print a square with a cross inside using stars (*).
* *
**
**
* *
12. Write a program to print a right-aligned half pyramid using stars (*).
**
***
****
13. Write a program to print an hourglass pattern using stars (*).
*******
*****
***
***
*****
*******
14. Write a program to print a hollow diamond using stars (*).
**
* *
*******
* *
**
15. Write a program to print an X using stars (*).
* *
**
**
* *