C Star Pattern Program

Following is the list of C programming displaying Star Pattern program:

Table of Content
  1. Square Star Pattern
  2. Hollow Square Star Pattern
  3. Rectangle Star Pattern
  4. Hollow Rectangle Star Pattern
  5. Right Triangle Star Pattern
  6. Hollow Right Triangle Star Pattern
  7. Mirrored Right Triangle Star Pattern
  8. Hollow Mirrored Right Triangle Star Pattern
  9. Water Image or Reverse Right Triangle Star Pattern
  10. Hollow Water Image or Reverse Right Triangle Star Pattern
  11. Inverted Right Triangle Star Pattern
  12. Hollow Inverted Right Triangle Star Pattern
  13. Pyramid Star Pattern
  14. Hollow Pyramid Star Pattern
  15. Reverse Pyramid Star Pattern
  16. Hollow Reverse Pyramid Star Pattern
  17. Hourglass Star Pattern
  18. Hollow Hourglass Star Pattern
  19. Diamond Star Pattern
  20. Hollow Diamond Star Pattern
  21. Half Right Diamond Star Pattern
  22. Half Left Diamond Star Pattern

1. Square Star Pattern

suare-star-pattern-program
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; }
suare-star-pattern-program

2. Hollow Square Star Pattern

hollow-suare-star-pattern-program
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; }
hollow-suare-star-pattern-program

3. Rectangle Star Pattern

rectangle-star-pattern-program
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; }
rectangle-star-pattern-program

4. Hollow Rectangle Star Pattern

hollow-rectangle-star-pattern-program
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; }
hollow-rectangle-star-pattern-program

5. Right Triangle Star Pattern

right-triangle-star-pattern-program
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; }
right-triangle-star-pattern-program

6. Hollow Right Triangle Star Pattern

hollow-right-triangle-star-pattern-program
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; }
hollow-right-triangle-star-pattern-program

7. Mirrored Right Triangle Star Pattern

mirrored-right-triangle-star-pattern-program
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; }
mirrored-right-triangle

8. Hollow Mirrored Right Triangle Star Pattern

hollow-mirrored-right-triangle-star-pattern-program
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; }
hollow-mirrored-right-triangle

9. Water Image or Reverse Right Triangle Star Pattern

water-image-or-reverse-right-triangle-star-pattern-program
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; }
water-image-or-reverse-right-triangle

10. Hollow Water Image or Reverse Right Triangle Star Pattern

hollow-water-image-or-reverse-right-triangle-star-pattern-program
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; }
hollow-water-image-or-reverse-right-triangle

11. Inverted Right Triangle Star Pattern

inverted-right-triangle-star-pattern-program
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; }
inverted-right-triangle-star-pattern-program

12. Hollow Inverted Right Triangle Star Pattern

hollow-inverted-right-triangle
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; }
hollow-inverted-right-triangle

13. Pyramid Star Pattern

pyramid-star-pattern-program
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; }
pyramid-star-pattern

14. Hollow Pyramid Star Pattern

hollow-pyramid
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; }
hollow-pyramid

15. Reverse Pyramid Star Pattern

reverse-pyramid
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; }
reverse-pyramid-star-pattern-program

16. Hollow Reverse Pyramid Star Pattern

hollow-reverse-pyramid-star-pattern-program
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; }
hollow-reverse-pyramid

17. Hourglass Star Pattern

hourglass-star-pattern-program
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; }
hourglass-star-pattern-program

18. Hollow Hourglass Star Pattern

hollow-hourglass
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; }
hollow-hourglass-star-pattern-program

19. Diamond Star Pattern

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; }
diamond-star-pattern-program

20. Hollow Diamond Star Pattern

hollow-diamond-star-pattern-program
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; }
hollow-diamond-star-pattern-program

21. Half Right Diamond Star Pattern

half-right-diamond-star-pattern-program
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; }
half-right-diamond-star-pattern-program

22. Half Left Diamond Star Pattern

half-left-diamond-star-pattern-program
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; }
half-left-diamond-star-pattern-program

Note:

  • All the programs are compiled and executed in Dev C++ code editor and save with .c extension.

More Topics