Showing posts with label Program to print string in formatted output form. Show all posts
Showing posts with label Program to print string in formatted output form. Show all posts

Thursday, July 21, 2011

Program to print string in formatted output form


/*Serial No.111     [swami88.cpp]*/ 

#include<stdio.h>
#include<conio.h>
#include<string.h>

void main()
{
int i;
char name[10]="math",a[]="aaaaaaaaaaaaaaa",c='y';
clrscr();
puts(name);
for(i=1;i<5;i++)
    {
    printf("%10.*s\n",i,name);
    }
printf("\n-----------------\n");
for(i=0;i<5;i++)
    {
    printf("%*c\n",i,c);
    }
for(i=5;i>0;i--)
    {
    printf("%*c\n",i,c);
    }
getch();
}


OUTPUT :
math
            m
          ma
        mat
      math

-----------------
y
  y
    y
      y
         y
       y
      y
    y
  y

y