Showing posts with label Format. Show all posts
Showing posts with label Format. Show all posts

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



C Program To Display The Number In A Specific Formats

How to write a C Program to display the number in a specific formats in C Programming Language ?


Solution For C Program :

/*C Program To Display The Number In A Specific Formats*/

#include<stdio.h>
void main()
{
int r, s, n, key;
printf("\nEnter the Value of n : ");
scanf("%d", &n);
key = 1;
for(r = 1; r <= n; r++)
{
for(s = 1; s <= r; s++)
printf("%3d", key++);
printf("\n");
}
}

You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable

C Program to Generate Specific Formats

How to write a C Program to generate specific formats in C Programming Language ?

Solution:

#include<stdio.h>
void main()
{
int r, s, n;
printf("\nEnter the Value of n : ");
scanf("%d", &n);
for(r = 1; r <= n; r++)
{
for(s = 1; s <= r; s++)
printf("*");
printf("\n");
}
}