formatting of output

Formatting of Outputs

Formatting of Outputs

In C programming we need lots of format specifier to work with various data types. Format specifiers defines the type of data to be printed on standard output. Whether to print formatted output or to take formatted input we need format specifiers. Format specifiers are also called as format string.

There are many format specifiers defined in C programming language :-

Format Specifiers

         Description

       %i or %d

 Integer Format Specifier

       %c

 Character Format  Specifier

       %f

 Float Format Specifier

       %s

 String Format Specifier

      %u

 Unsigned Format  Specifier

      %ld

 Long Integer Format  Specifier

Formatting of integers

The %d format specifier is implemented for representing integer values. This is used with printf() function for printing the integer value stored in the variable.

      Syntax printf("%d",<variable name>);

Formatting of floating point values

The %f format specifier is implemented for representing fractional values. This is implemented within printf() function for printing the fractional or floating value stored in the variable. Whenever you need to print any fractional or floating data, you have to use %f format specifier.

      Syntax : printf("%f",<variable name>);

Formatting of characters

The %c format specifier is implemented for representing characters. This is used with printf() function for printing the character stored in a variable. When you want to print a character data, you should incorporate the %c format specifier.

      Syntax : printf("%c",<variable name>);

 
This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free