String Pattern in C programming
|
#include<stdio.h> #include<conio.h> main() { int x,y; char
name[]="COMPUTER"; for(x=0;x<8;x++) { for(y=x;y<8;y++) { printf("%c",name[y]); } printf("\n"); } getch(); } |
|
#include<stdio.h> #include<conio.h> main() { int x,y; char
name[]="COMPUTER"; for(x=0;x<8;x++) { for(y=0;y<=x;y++) { printf("%c",name[y]); } printf("\n"); } getch(); } |
|
#include<stdio.h> #include<conio.h> main() { int x,y;
char
name[]="COMPUTER"; for(x=0;x<8;x++) { for(y=0;y<=x;y++) { printf("%c",name[x]); } printf("\n"); } getch(); } |
|
#include<stdio.h> #include<conio.h> main() { int x,y; char name[]="COMPUTER"; for(x=0;x<8;x++) { for(y=x;y<8;y++) { printf("%c",name[x]); } printf("\n"); } getch(); } |
|
#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; } |
|
#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; } |
|
#include <stdio.h> #include <conio.h> main() { int i, j, rows, k = 0; printf (" Enter how many rows:
\n"); scanf ("%d", &rows); for ( i =1; i <= rows; i++) { for ( j = 1; j <= rows - i;
j++) {
printf (" ");
}
for ( k = 1; k <= ( 2 *
i - 1); k++) {
printf ("* "); }
printf ("\n"); } } |
|
#include <stdio.h> #include <conio.h> main() { int i, j, rows, k, m = 1; printf (" Enter how many rows:
\n"); scanf ("%d", &rows); printf("\n"); for ( i = rows; i >= 1; i--) { for ( j = 1; j <= m; j++) {
printf (" ");
}
for ( k = 1; k <= ( 2 * i - 1);
k++) {
printf ("* "); }
m++;
printf ("\n"); } getch();
} |
No comments:
Post a Comment