Friday, May 21, 2010

Printing Sequence


/*
* Printing_Sequence.c
*
* Created on: May 21, 2010
* Author: karthikeyan.D
*
*/
#include<stdio.h>
#include<string.h>
int main()
{
int c, d,len;
static char string[]="WelcomeTamilnadu";
len=strlen(string);
printf("\n\n");
printf("-------------------\n");
for(c=0;c<=len-1;c++)
{
d=c+1;
printf("|%-16.*s|\n",d,string);
}
printf("-------------------\n");
for(c=len;c>=0;c--)
{
d=c+1;
printf("|%-16.*s|\n",d,string);
}
printf("-------------------\n");
return 0;
}

OUTPUT:

-------------------
|W |
|We |
|Wel |
|Welc |
|Welco |
|Welcom |
|Welcome |
|WelcomeT |
|WelcomeTa |
|WelcomeTam |
|WelcomeTami |
|WelcomeTamil |
|WelcomeTamiln |
|WelcomeTamilna |
|WelcomeTamilnad |
|WelcomeTamilnadu|
-------------------
|WelcomeTamilnadu|
|WelcomeTamilnadu|
|WelcomeTamilnad |
|WelcomeTamilna |
|WelcomeTamiln |
|WelcomeTamil |
|WelcomeTami |
|WelcomeTam |
|WelcomeTa |
|WelcomeT |
|Welcome |
|Welcom |
|Welco |
|Welc |
|Wel |
|We |
|W |
-------------------

No comments:

Post a Comment