Tuesday, October 13, 2009

star

#include"stdio.h"
#include"string.h"
#include"conio.h"
/*Write a program to print the following output
A B C D E F G F E D C B A
A B C D E F F E D C B A
A B C D E E D C B A
A B C D D C B A
A B C C B A
A B B A
A A
*/
int main()
{
int i,k=1,j=1,len,size;
char let[]={'A','B','C','D','E','F','G','\0'};
len=strlen(let);
size=len;
printf("string len is %d\n\n",len);
for(i=0;i printf("%c",let[i]);
for(i=len-2;i>=0;i--)
printf("%c",let[i]);
printf("\n");printf("\n");

while(k<size)
{
for(i=0;i<len-1;i++)
printf("%c",let[i]);
for(i=0;i<(1*j);i++)
printf(" ");
for(i=len-2;i>=0;i--)
printf("%c",let[i]);

j=j+2;
k++;
len--;
printf("\n");printf("\n");
}
getch();
return 0;
}

No comments:

Post a Comment