P rinting p atterns in C prog ramming is very easy. H ere we are printing the equilateral triangle of numbers . #include<stdio.h> int main() { int i,j,k,l,n,val; printf("no of lines="); scanf("%d",&n); for(i=1;i<=n;i++) { printf("\n"); for(j=1;j<=n-i;j++) { printf(" "); } for(k=1;k<=i;k++) { printf("%d",k);} for(l=i-1;l>=1;l--) printf("%d",l); } return 0; } OUTPUT- no of lines=6 1 121 12321 1234321 123454321 12345654321
Posts
#include<stdio.h> int main() { int i,j,k,l,n,val; printf("no of lines="); scanf("%d",&n); for(i=1;i<=n;i++) { printf("\n"); for(j=1;j<=n-i;j++) { printf(" "); } for(k=1;k<=i;k++) { printf("%d",k);} for(l=i-1;l>=1;l--) printf("%d",l); } return 0; } OUTPUT- no of lines=6 1 121 12321 1234321 123454321 12345654321