Following is the list of C programming displaying Star Pattern program:
Table of Content
- Square Star Pattern
- Hollow Square Star Pattern
- Rectangle Star Pattern
- Hollow Rectangle Star Pattern
- Right Triangle Star Pattern
- Hollow Right Triangle Star Pattern
- Mirrored Right Triangle Star Pattern
- Hollow Mirrored Right Triangle Star Pattern
- Water Image or Reverse Right Triangle Star Pattern
- Hollow Water Image or Reverse Right Triangle Star Pattern
- Inverted Right Triangle Star Pattern
- Hollow Inverted Right Triangle Star Pattern
- Pyramid Star Pattern
- Hollow Pyramid Star Pattern
- Reverse Pyramid Star Pattern
- Hollow Reverse Pyramid Star Pattern
- Hourglass Star Pattern
- Hollow Hourglass Star Pattern
- Diamond Star Pattern
- Hollow Diamond Star Pattern
- Half Right Diamond Star Pattern
- Half Left Diamond Star Pattern
1. Square Star Pattern
Program
#include<stdio.h> int main() { int i, j, size = 7; for (i = 0; i < size; i++) { for (j = 0; j < size; j++) { printf("*"); } printf("\n"); } return 0; }
2. Hollow Square Star Pattern
Program
#include<stdio.h> int main() { int i, j, size = 7; for (i = 0; i < size; i++) { for (j = 0; j < size; j++) { if (i == 0 || i == size - 1) { printf("*"); } else { if (j == 0 || j == size - 1) { printf("*"); } else { printf(" "); } } } printf("\n"); } return 0; }
3. Rectangle Star Pattern
Program
#include<stdio.h> int main() { int i, j, rows=5, columns=10; for(i = 0; i < rows; i++) { for(j = 0; j < columns; j++) { printf("*"); } printf("\n"); } return 0; }
4. Hollow Rectangle Star Pattern
Program
#include<stdio.h> int main() { int i, j, rows=4, columns=15; for(i = 0; i < rows; i++) { for(j = 0; j < columns; j++) { if(i == 0 || i == rows-1 || j == 0 || j == columns-1) { printf("*"); } else { printf(" "); } } printf("\n"); } return 0; }
5. Right Triangle Star Pattern
Program
#include<stdio.h> int main() { int i, j, size = 4; for (i = 0; i < size; i++) { for (j = 0; j <= i; j++) { printf("*"); } printf("\n"); } return 0; }
6. Hollow Right Triangle Star Pattern
Program
#include<stdio.h> int main() { int i, j, size = 7; for (i = 1; i <= size; i++) { for (j = 0; j < i; j++) { if (i != size) { if (j == 0 || j == i-1) { printf("*"); } else { printf(" "); } } else { printf("*"); } } printf("\n"); } return 0; }
7. Mirrored Right Triangle Star Pattern
Program
#include<stdio.h> int main() { int i, j, k, size = 7; for (i = 0; i < size; i++) { for (j = 1; j < size-i; j++) { printf(" "); } for (k = 0; k <= i; k++) { printf("*"); } printf("\n"); } return 0; }
8. Hollow Mirrored Right Triangle Star Pattern
Program
#include<stdio.h> int main() { int i, j, size=7; for(i = 1; i <= size; i++) { for(j = 1; j <= size - i; j++) { printf(" "); } if(i == 1 || i == size) { for(j = 1; j <= i; j++) { printf("*"); } } else { for(j = 1; j <= i; j++) { if(j == 1 || j == i) { printf("*"); } else { printf(" "); } } } printf("\n"); } return 0; }
9. Water Image or Reverse Right Triangle Star Pattern
Program
#include<stdio.h> int main() { int i , j, size = 5; for (i = 0; i < size; i++) { for (j = 0; j < i; j++) { printf(" "); } for (j = size; j > i; j--) { printf("*"); } printf("\n"); } return 0; }
10. Hollow Water Image or Reverse Right Triangle Star Pattern
Program
#include<stdio.h> int main() { int i, j, size=7; for(i = size; i > 0; i--) { for(j = size - i; j > 0; j--) { printf(" "); } if(i == 1 || i == size) { for(j = 1; j <= i; j++) { printf("*"); } } else { for(j = 1; j <= i; j++) { if(j == 1 || j == i) { printf("*"); } else { printf(" "); } } } printf("\n"); } return 0; }
11. Inverted Right Triangle Star Pattern
Program
#include<stdio.h> int main() { int i, j, size = 5; for (i = 0; i < size; i++) { for (j = 0; j < size-i; j++) { printf("*"); } printf("\n"); } return 0; }
12. Hollow Inverted Right Triangle Star Pattern
Program
#include<stdio.h> int main() { int i, j, size=8; for(i = size; i > 0; i--) { if(i == 1 || i == size) { for(j = 1; j <= i; j++) { printf("*"); } } else { for(j = 1; j <= i; j++) { if(j == 1 || j == i) { printf("*"); } else { printf(" "); } } } printf("\n"); } return 0; }
13. Pyramid Star Pattern
Program
#include<stdio.h> int main() { int i, j, k, size = 8; for (i = 0; i < size; i++) { for (j = 0; j < size-i-1; j++) { printf(" "); } for (k = 0; k < 2*i+1; k++) { printf("*"); } printf("\n"); } return 0; }
14. Hollow Pyramid Star Pattern
Program
#include<stdio.h> int main() { int i, j, k, size = 7; for (i = 0; i < size; i++) { for (j = 0; j < size-i-1; j++) { printf(" "); } for (k = 0; k < 2*i+1; k++) { if (i == 0 || i == size-1) { printf("*"); } else { if (k == 0 || k == 2*i) { printf("*"); } else { printf(" "); } } } printf("\n"); } return 0; }
15. Reverse Pyramid Star Pattern
Program
#include<stdio.h> int main() { int i, j, k, size = 7; for (i = 0; i < size; i++) { for (j = 0; j < i; j++) { printf(" "); } for (k = 0; k < 2*(size-i)-1; k++) { printf("*"); } printf("\n"); } return 0; }
16. Hollow Reverse Pyramid Star Pattern
Program
#include<stdio.h> int main() { int i, j, rows=7; for(i = rows; i > 0; i--) { for(j = 1; j <= rows - i; j++) { printf(" "); } if(i == 1 || i == rows) { for(j = 1; j <= i * 2 - 1; j++) { printf("*"); } } else { for(j = 1; j <= i * 2 - 1; j++) { if(j == 1 || j == i * 2 - 1) { printf("*"); } else { printf(" "); } } } printf("\n"); } return 0; }
17. Hourglass Star Pattern
Program
#include<stdio.h> int main() { int i, j, k, size = 5; for (i = 0; i < size; i++) { for (j = 0; j < i; j++) { printf(" "); } for (k = 0; k < (size-i)*2-1; k++) { printf("*"); } printf("\n"); } for (i = 2; i <= size; i++) { for (j = size; j > i; j--) { printf(" "); } for (k = 0; k < i*2-1; k++) { printf("*"); } printf("\n"); } return 0; }
18. Hollow Hourglass Star Pattern
Program
#include<stdio.h> int main() { int size=7, i, j, k; for (i = 1; i <= size; i++) { for (j = 1; j < i; j++) { printf(" "); } for (k = i; k <= size; k++) { if (i == 1 || k == i || k == size) { printf("* "); } else { printf(" "); } } printf("\n"); } for (i = size - 1; i >= 1; i--) { for (j = 1; j < i; j++) { printf(" "); } for (k = i; k <= size; k++) { if (i == 1 || k == i || k == size) { printf("* "); } else { printf(" "); } } printf("\n"); } return 0; }
19. Diamond Star Pattern
Program
#include<stdio.h> int main() { int i, j, k, size = 8; for (i = 1; i <= size; i++) { for (j = size; j > i; j--) { printf(" "); } for (k = 0; k < i*2-1; k++) { printf("*"); } printf("\n"); } for (i = 1; i <= size-1; i++) { for (j = 0; j < i; j++) { printf(" "); } for (k = (size-i)*2-1; k > 0; k--) { printf("*"); } printf("\n"); } return 0; }
20. Hollow Diamond Star Pattern
Program
#include<stdio.h> int main() { int i, j, k, size = 7; for (i = 1; i <= size; i++) { for (j = size; j > i; j--) { printf(" "); } for (k = 0; k < i*2-1; k++) { if (k == 0 || k == 2*i-2) { printf("*"); } else { printf(" "); } } printf("\n"); } for (i = 1; i < size; i++) { for (j = 0; j < i; j++) { printf(" "); } for (k = (size-i)*2-1; k >= 1; k--) { if (k == 1 || k == (size-i)*2-1) { printf("*"); } else { printf(" "); } } printf("\n"); } return 0; }
21. Half Right Diamond Star Pattern
Program
#include<stdio.h> int main() { int i, j, size = 9; for (i = 1; i <= size; i++) { for (j = 0; j < i; j++) { printf("*"); } printf("\n"); } for (i = 1; i <= size-1; i++) { for (j = 0; j < size-i; j++) { printf("*"); } printf("\n"); } return 0; }
22. Half Left Diamond Star Pattern
Program
#include<stdio.h> int main() { int i, j, k, size = 7; for (i = 1; i <= size; i++) { for (j = 0; j < size-i; j++) { printf(" "); } for (k = 0; k < i; k++) { printf("*"); } printf("\n"); } for (i = 1; i <= size-1; i++) { for (j = 0; j < i; j++) { printf(" "); } for (k = 0; k < size-i; k++) { printf("*"); } printf("\n"); } return 0; }
Note:
- All the programs are compiled and executed in Dev C++ code editor and save with .c extension.