#include<stdio.h>
void main()
{
char *m1="Binary";
char *m2="Decimal";
char *m3="Octal";
char *m4="Hexadecimal";
float dl=10000.123;
int n=1,f=1;
puts("Outputting a number with different field widths./n" );
printf("%5f/n",dl);
printf("%10f/n",dl);
printf("%15f/n",dl);
printf("%20f/n",dl);
printf("%25f/n",dl);
puts("/n Press Enter to continue...");
fflush(stdin);
getchar();
puts("/nUser the * field width specifier to obtain field width");
puts("from a variable in the argumeng list./n");
for(n=5;n<=25;n+=5)
{
printf("%*f/n",n,dl);
}
puts("/n Press Rnter to continue...");
fflush(stdin);
getchar();
puts("/n Include leading zeros./n");
printf("%05f/n",dl);
printf("%010f/n",dl);
printf("%015f/n",dl);
printf("%020f/n",dl);
printf("%025f/n",dl);
puts("/n Press Enter to continue...");
fflush(stdin);
getchar();
puts("/nDisplay in octal,decimal,and hexadecimal.");
puts("Use # to precede octal and hex output with 0 and0X.");
puts("Use - to left-justify each value in its field.");
puts("First display column labels./n");
printf("%-15s%-15s%-15s",m2,m3,m4);
for(n=1;n<20;n++)
{
printf("/n%-15d%-#15o%-#15X",n,n,n);
}
puts("/n Press Enter to continue...");
fflush(stdin);
getchar();
puts("/n/nUse the %n conversion command to count characters./n");
printf("%s%s%s%s%n",m1,m2,m3,m4,&n);
printf("/n/nThe last printf() output %d characters./n",n);
}