Search This Blog

Translate

C program to display data in different format, right alignment, left Alignment

different format specifiers in c,c program for different patterns,double format specifier in c,c program template

void main()
{
    char f1[]="CProgramming";
    int f2=21230;
    float f3=21.2698734;
    clrscr();
    printf("**********First Format***************");
    printf("\n\nLeft alignment is=%-20s",f1);
    printf("\n\nRight alignment is=%20s",f1);
    printf("\n\nFirst five character is=%20.5s",f1);
    printf("\n\nFirst five character with left alignment=%-20.5s",f1);
    printf("\n\n\n**********Second Format***************");
    printf("\n\nLeft alignment is=%-10d",f2);
    printf("\n\nRight alignment is=%10d",f2);
    printf("\n\nFirst three digit is=%10.3d",f2);
    printf("\n\nFirst three digit with left alignment=%-20.3d",f2);
    printf("\n\nDisplay with sign is=%+10d",f2);
    printf("\n\nDisplay with leading zero's=%010d",f2);
    printf("\n\nDisplay with sign and leading zero's=%+010d",f2);
    printf("\n\n\n**********Third Format***************");
    printf("\n\nLeft alignment is=%-10.3f",f3);
    printf("\n\nRight alignment is=%10.3f",f3);
    printf("\n\nFirst three digit is=%10.3f",f3);
    printf("\n\nFirst three digit with left alignment=%-10.3f",f3);
    printf("\n\nDisplay with sign is=%+10.3f",f3);
    printf("\n\nDisplay with leading zero's=%010.3f",f3);
    printf("\n\nDisplay with sign and leading zero's=%+010.3f",f3);
    printf("\n\nDisplay data for precision 5 is=%10.5f",f3);
    getch();
}

 

C program to display data in different format, right alignment, left Alignment, different format specifiers in c,c program for different patterns,double format specifier in c,c program template

 

C Program example List

Google+ Badge