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 [email protected]
* 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("%dnn", num1);
printf("%10dnn", num1);
printf("%010dnn", num1);
printf("%-10dnn", num1);
printf("%10ldnn", num2);
printf("%10ldnn", -num2);
printf("%7.4fnn", num3);
printf("%fnn", num3);
printf("%7.2fnn", num3);
printf("%-7.2fnn", num3);
printf("%07.2fnn", num3);
printf("%*.*f", 7, 2, num3);
printf("%10.2enn", num3);
printf("%12.4enn", -num3);
printf("%-10.2enn", num3);
printf("%enn", 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 Follow @c_program

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!

(c) www.c-program-example.com

Leave a Reply