This is the C code for creating above star.
//www.codeSriLanka.blogspot.com
//www.codeSriLanka.blogspot.com
//14/09/2011
#include<stdio.h>
int main(){
int i,j,k;
for(i=1;i<=5;i++){
for(j=15;j>=i;j--){
printf(" ");
}
for(k=1;k<=i;k++){
if(k==1 || k==i){
printf("* ");
}
else
printf(" ");
}
printf("\n");
}
for(i=1;i<=5;i++){
for(j=1;j<=i;j++){
printf(" ");
}
for(k=15;k>=i;k--){
if(k==i || k==15 || i==1 && k!=6 &&k!=7 && k!=8 && k!=9 &&k!=10){
printf("* ");
}
else
printf(" ");
}
printf("\n");
}
for(i=1;i<=5;i++){
for(j=5;j>=i;j--){
printf(" ");
}
for(k=1;k<=i+10;k++){
if(k==1 || k==i+10 ||i==5 && k!=6 &&k!=7 && k!=8 && k!=9 &&k!=10){
printf("* ");
}
else
printf(" ");
}
printf("\n");
}
No comments:
Post a Comment