the difficulties I faced when I tried
writing them.
You should try doing it yourself but in
case of any difficulty,
feel free to
consult the codes below.
NOTE: All written in C language
*
***
*****
*******
*********
code:
#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;
}
Same pattern as above but this time, you ask the user to determine the row
*
**
***
****
*****
code:
#include <stdio.h>
int main() {
int n, c, k;
printf("Enter number of rows\n");
scanf("%d",&n);
for ( c = 1 ; c <= n ; c++ ) {
for( k = 1 ; k <= c ; k++ )
printf("*");
printf("\n");
}
return 0;
}
Another pattern
*********
*******
*****
***
*
code:
#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;
}
You can manipulate the codes above to suit your taste. lol
Hope it was helpful.
Greetings,
No comments:
Post a Comment