Numeric pattern in C programming
1 12 123 1234 12345 |
#include <stdio.h> #include <conio.h> main() { int x,y; for (x=1;x<=5;x++) { for (y=1;y<=x;y++) { printf("%d",y); } printf("\n"); } getch(); } |
54321 5432 543 54 5 |
#include <stdio.h> #include <conio.h> main() { int x,y; for (x=1;x<=5;x++) { for (y=5;y>=x;y--) { printf("%d",y); } printf("\n"); } getch(); } |
5 54 543 5432 54321
|
#include <stdio.h> #include <conio.h> main() { int x,y; for (x=5;x>=1;x--) { for (y=5;y>=x;y--) { printf("%d",y); } printf("\n"); } getch(); } |
12345 1234 123 12 1 |
#include <stdio.h> #include <conio.h> main() { int x,y; for (x=5;x>=1;x--) { for (y=1;y<=x;y++) { printf("%d",y); } printf("\n"); } getch(); } |
55555 4444 333 22 1 |
#include <stdio.h> #include <conio.h> main() { int x,y; for (x=5;x>=1;x--) { for (y=1;y<=x;y++) { printf("%d",x); } printf("\n"); } getch(); } |
5 44 333 2222 11111
|
#include <stdio.h> #include <conio.h> main() { int x,y; for (x=5;x>=1;x--) { for (y=5;y>=x;y--) { printf("%d",x); } printf("\n"); } getch(); } |
1 2
3 4
5 6 7
8 9 10 |
#include<stdio.h> #include<conio.h> main() { int i,j=1,k; for(i=1;i<5;++i) { for(k=1;k<=i;j++,k++) printf("%d\t",j); printf("\n"); } getch(); } |
|
#include<conio.h> #include<stdio.h> main() { int x,y; for (x=0;x<=5;x++) { for (y=1;y<=5;y++) { printf("%d\t",(x+y)*10); } printf("\n"); } getch(); } |
1 21 321 4321 54321 |
#include <stdio.h> #include<conio.h> main() {
int i, j;
for(i=1; i<=5; i++)
{ for(j=i; j>=1; j--) { printf("%d", j); }
printf("\n");
}
getch(); } |
5 45 345 2345 12345 |
#include <stdio.h> #include<conio.h> int main() {
int i, j;
for(i=5; i>=1; i--)
{ for(j=i; j<=5; j++) { printf("%d", j); }
printf("\n");
}
getch(); } |
1 23 345 4567 56789 |
#include <stdio.h> #include<conio.h> int main() {
int i, j, k;
for(i=1; i<=5; i++)
{ k = i;
for(j=1; j<=i; j++, k++) { printf("%d", k); }
printf("\n");
}
getch(); } |
11111 2222 333 44 5 |
#include <stdio.h> #include<conio.h> main() {
int i, j;
for(i=1; i<=5; i++)
{ for(j=i; j<=5; j++) { printf("%d", i); }
printf("\n");
}
getch(); } |
No comments:
Post a Comment