#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char c[20];
int i,j,len;
clrscr();
printf("\nEnter the string: ");
gets(c);
len=strlen(c);
for(i=0;i<len;i++)
{
for(j=0;j<=i;j++)
{
printf("%c",c[j]);
}
printf("\n");
}
for(i=len-1;i>0;i--)
{
for(j=0;j<i;j++)
{
printf("%c",c[j]);
}
printf("\n");
}
getch();
}
//OUTPUT:
//Enter the
string: abcd
a
ab
abc
abcd
abc
ab
a
Thnx
ReplyDeleteThanks this is very good example of for loop program of printing star patterns.
ReplyDeleteThank you
ReplyDeletePlz give explanation
ReplyDelete