Friday, 6 February 2015

pattern 2 program

if n=7 * * * * * * * * * * * * * * * * #include <stdio.h> void draw_line(int nst,int n) { int i; int nsp=(n-nst)/2; for (i=0;i<nsp;i++) printf(" "); for (i=0;i<nst;i++) printf("*"); printf("\n"); } void draw_pattern(int nst,int n) { if(nst==1) draw_line(nst,n); else { draw_pattern(nst-2,n); draw_line(nst,n); } } void main() { draw_pattern(7,7); }

No comments:

Post a Comment