/*write a c program to accept string from user & generate the following pattern
a
ab
abc
ab
a
*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[20];
int n,i,j,c,k;
clrscr();
printf("enter the string :");
gets(a);
c=strlen(a);
printf("\n\n");
printf("the display of pattern");
for(i=0;i<c;i++)
{
for(j=0;j<=i;j++)
{
printf("%c",a[j]);
}
printf("\n");
}
n=c-1;
for(i=n;i>=0;i--)
{
for(j=0;j<i;j++)
{
printf("\%c",a[j]);
}
printf("\n");
}
getch();
}
No comments:
Post a Comment