0% found this document useful (0 votes)
16 views

Format

The document demonstrates the use of format specifiers in C printf statements to control output formatting of integers, floating point numbers, and strings. It shows how %d controls integer output width and padding, %f controls floating point number of decimal places and scientific notation, and %s controls string output width and number of characters printed.

Uploaded by

rangarajantr
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Format

The document demonstrates the use of format specifiers in C printf statements to control output formatting of integers, floating point numbers, and strings. It shows how %d controls integer output width and padding, %f controls floating point number of decimal places and scientific notation, and %s controls string output width and number of characters printed.

Uploaded by

rangarajantr
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Formatted output (printf)

printf(%d,1234);
printf(%6d,1234);
printf(%2d,1234);
printf(%-6d,1234);
printf(%06d,1234);

1234
1234
1234
1234
001234

x = 12.3456;
printf(%7.4f,x);
printf(%7.2f,x);
printf(%-7.2f,x);
printf(%f,x);
printf(%10.2e,x);
printf(%11.4e,-x);
printf(%-10.2e,x);
printf(%e,x);

12.3456
12.35
12.35
12.3456
1.23e+01
-1.2345e+01
1.23e+01
1.234560e+01

s=
cse class 123456
%s
cse class 123456
%20s
cse class 123456
%20.10s
cse class
%.5s
cse c
%-20.10s cse class
%5s
cse class 123456

You might also like