C Code 9 _ To print the given string with border formed with *
Program:
#include<stdio.h>
#include<string.h>
int main()
{
char a[50];
int i,j,l,ll,mid,k=0;
printf("Enter a string : ");
gets(a);
l=strlen(a);
ll=l+4;
mid=ll/2;
for(i=0;i<ll;i++)
{
for(j=0;j<ll;j++)
{
if(i==0||i==ll-1||j==0||j==ll-1)
{
printf("*");
}
else
if((i==mid)&&(j>1))
{
printf("%c",a[k]);
k=k+1;
}
else
{
printf(" ");
}
}
printf("\n");
}
getch();
return 0;
}
Output:
Thank You ...
0 comments: