- Generate the Pattern
- *
* *
* * *
* * * *
* * * * *#include<stdio.h>int main(){int i,j;for(i=0;i<5;i++){printf("\n");for(j=i;j<5;j++){printf("%2c",'*');}}return 0;} - Generate the Pattern
* * * *
* * *
* *
*#include<stdio.h>int main(){int i,j;for(i=0;i<4;i++){printf("\n");for(j=i;j<4;j++){printf("* ");}}return 0;} - Generate the Pattern
* * * *
* * *
* *
*#include<stdio.h>int main(){int i,j;for(i=0;i<4;i++){printf("\n");for(j=0;j<4;j++){if(i<=j){printf("%2c",'*');}else{printf("%2c",' ');}}}return 0;} - Generate the Pattern
*
* *
* * *
* * * *#include<stdio.h>int main(){int i,j;for(i=3;i>=0;i--){printf("\n");for(j=0;j<4;j++){if(i<=j){printf("%2c",'*');}else{printf("%2c",' ');}}}return 0;} - Generate the Pattern
*
* *
* * *
* * * *
* * * * *#include<stdio.h>int main(){int i,j;for(i=5;i>=0;i--){printf("\n");for(j=0;j<5;j++){if(i<=j){printf("%2c",'*');}printf("%2c",' ');}}return 0;} - Generate the Pattern
* * * *
* * *
*#include<stdio.h>int main(){int i,j;for(i=0;i<4;i++){printf("\n");for(j=0;j<4;j++){if(i<=j){printf("%2c",'*');}printf("%2c",' ');}}return 0;} - Generate The Pattern
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1 - Generate the pattern
A B C D E F G F E D C B A
A B C D E F F E D C B A
A B C D E E D C B A
A B C D D C B A
A B C C B A
A B B A
A A#include <stdio.h>int main() {int rows = 7;int i, j;char ch;for (i = 0; i < rows; i++) {// Print characters increasingfor (j = 0, ch = 'A'; j < 7 - i; j++, ch++) {printf("%c ", ch);}// Print spacesfor (j = 0; j < 2 * i; j++) {printf(" ");}// Print characters decreasingfor (ch -= 2, j = 0; j < 7 - i; j++, ch--) {printf("%c", ch);if (j < 6 - i) printf(" ");}printf("\n");}return 0;} - Generate the pattern
1
2 3
4 5 6
7 8 9 10#include <stdio.h>int main() {int rows = 4;int space, i, j, count = 1;for (i = 1; i <= rows; i++) {for (space = i; space < rows; space++)printf(" ");for (j = 1; j <= i; j++) {printf("%-3d", count);count++;}printf("\n");}return 0;}
#include <stdio.h>
int main() {
int rows = 5;
int coef = 1;
for(int i = 0; i < rows; i++) {
// Print spaces
for(int space = 1; space <= rows - i; space++)
printf(" ");
for(int j = 0; j <= i; j++) {
// Print coefficients
if (j == 0 || i == 0)
coef = 1;
else
coef = coef * (i - j + 1) / j;
printf("%6d", coef);
}
printf("\n");
}
return 0;
}

0 Comments had been done yet:
Post a Comment