C Program To Print String In Formatted Output Form

How to write a C Program To Print String In Formatted Output Form in C Programming Language ?


Solution For C Program :

/*C Program To Print String In Formatted Output Form.*/

#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



You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable




Learn More :