Hexadecimal representation format specifier signed unsigned code example

Example 1: format specifier fro float in printf

printf("%0k.yf" float_variable_name)

Here k is the total number of characters you want to get printed. k = x + 1 + y (+ 1 for the dot) and float_variable_name is the float variable that you want to get printed.

Suppose you want to print x digits before the decimal point and y digits after it. Now, if the number of digits before float_variable_name is less than x, then it will automatically prepend that many zeroes before it.

Example 2: what are format specifiers

it is used during taking input and out put

Int ("%d"): 
Long ("%ld"):
Char ("%c"): 
Float ("%f"): 
Double ("%lf")

example:

char ch = 'd';
double d = 234.432;
printf("%c %lf", ch, d);

char ch;
double d;
scanf("%c %lf", &ch, &d);

Tags:

Misc Example