Oct 21, 2011

C Program to demonstrate Formatting of Integers, Real Numbers and Strings.

C Program to format the outputs of Integers, Floats and Strings. Here we gives the all the format specifiers example. Read more about C Programming Language .

* You can use all the programs on  www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact info@c-program-example.com
* To find more C programs, do visit www.c-program-example.com
* and browse!
*                      Happy Coding


main() {
 int num1 = 12345;
 long num2 = 987654;
 float num3 = 98.7654;
 printf("%d\n\n", num1);
 printf("%10d\n\n", num1);
 printf("%010d\n\n", num1);
 printf("%-10d\n\n", num1);
 printf("%10ld\n\n", num2);
 printf("%10ld\n\n", -num2);
 printf("%7.4f\n\n", num3);
 printf("%f\n\n", num3);
 printf("%7.2f\n\n", num3);
 printf("%-7.2f\n\n", num3);
 printf("%07.2f\n\n", num3);
 printf("%*.*f", 7, 2, num3);
 printf("%10.2e\n\n", num3);
 printf("%12.4e\n\n", -num3);
 printf("%-10.2e\n\n", num3);
 printf("%e\n\n", num3);
 printf(":%s:\n", "Hello, world!");
 printf(":%15s:\n", "Hello, world!");
 printf(":%.10s:\n", "Hello, world!");
 printf(":%-10s:\n", "Hello, world!");
 printf(":%-15s:\n", "Hello, world!");
 printf(":%.15s:\n", "Hello, world!");
 printf(":%15.10s:\n", "Hello, world!");
 printf(":%-15.10s:\n", "Hello, world!");
Read more Similar C Programs
Learn C Programming

Simple C Programs

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!