Star Patterns - some very useful examples of Star Patterns C program are as follows.
Star Pattern - 1
* *** ***** ******* *********
C program
#include<stdio.h> int main() { int i, j, k; for(i=1;i<=5;i++) { for(j=i;j<5;j++) { printf(" "); } for(k=1;k < (i*2);k++) { printf("*"); } printf("\n"); } return 0; }=============================================
Star Pattern - 2
********* ******* ***** *** *
C program
#include<stdio.h> int main() { int i, j, k; for(i=5;i>=1;i--) { for(j=5;j>i;j--) { printf(" "); } for(k=1;k < (i*2);k++) { printf("*"); } printf("\n"); } return 0; }=============================================
Star Pattern - 3
********** **** **** *** *** ** ** * * ** ** *** *** **** **** **********
C program
#include<stdio.h> int main() { int i, j, k; for(i=1;i<=5;i++) { for(j=1;j<=6-i;j++) { printf("*"); } for(k=1;k < i;k++) { printf(" "); } for(j=1;j<=6-i;j++) { printf("*"); } printf("\n"); } for(i=2;i<=5;i++) { for(j=1;j<=i;j++) { printf("*"); } for(k=1;k <= 5-i;k++) { printf(" "); } for(j=1;j<=i;j++) { printf("*"); } printf("\n"); } return 0; }=============================================
Star Pattern - 4
* *** ***** ******* ********* ******* ***** *** *
C program
#include<stdio.h> int main() { int i, j, k; for(i=1;i<=5;i++) { for(j=i;j<5;j++) { printf(" "); } for(k=1;k < (i*2);k++) { printf("*"); } printf("\n"); } for(i=4;i>=1;i--) { for(j=5;j>i;j--) { printf(" "); } for(k=1;k < (i*2);k++) { printf("*"); } printf("\n"); } return 0; }=============================================
Star Pattern - 5
* ** *** **** *****
C program
#include<stdio.h> int main() { int i, j; for(i=1;i<=5;i++) { for(j=1;j<=i;j++) { printf("*"); } printf("\n"); } return 0; }=============================================
Star Pattern - 6
***** **** *** ** *
C program
#include<stdio.h> int main() { int i, j; for(i=5;i>=1;i--) { for(j=1;j<=i;j++) { printf("*"); } printf("\n"); } return 0; }=============================================
Star Pattern - 7
* ** *** **** *****
C program
#include<stdio.h> int main() { int i, j, k; for(i=5;i >= 1;i--) { for(j=1;j < i;j++) { printf(" "); } for(k=5;k >= i;k--) { printf("*"); } printf("\n"); } return 0; }=============================================
Star Pattern - 8
***** **** *** ** *
C program
#include<stdio.h> int main() { int i, j, k; for(i=5;i>=1;i--) { for(j=5;j>i;j--) { printf(" "); } for(k=1;k <= i;k++) { printf("*"); } printf("\n"); } return 0; }=============================================
Star Pattern - 9
* * * * * * * * * * * * * * * *
C program
#include<stdio.h> int main() { int i, j; for(i=1; i<=5; i++) { for(j=5; j>i; j--) { printf(" "); } printf("*"); for(j=1; j<(i-1)*2; j++) { printf(" "); } if(i==1) printf("\n"); else printf("*\n"); } for(i=4; i>=1; i--) { for(j=5; j>i; j--) { printf(" "); } printf("*"); for(j=1; j<(i-1)*2; j++) { printf(" "); } if(i==1) printf("\n"); else printf("*\n"); } return 0; }=============================================
No comments:
Post a Comment