Comments
Comments
a,b,c; // here I am declaring the variables scanf(%d%d,&a,&b); //getting inputs c=a+b; printf(%d,c); }
form.
u Unsigned integers in decimal form. x Unsigned integers in hexadecimal form,
printing characters.
s String
exponential form. one digit to the left of the decimal point; right side of the decimal point depends on the required precision.
Field-width
1.
Field-width indicates the least number of columns that will be allocated to the output.
Printf(%4d,a);
if value of a is 10 >>>bb10
2.
if a is 12345 then 5 columns are used, even if %4d is specified. In any circumstance, the output width is not shortened, because of fieldwidth. If you specify * instead of field-width then you have to specify additional arguments.
3.
4.
Precision
1.
Precision indicates the minimum number of digits printed for type integers d, i, o, u, x, and X.
For example,
printf("%10.4d\n", 35); o/p - bbbbbb0035 printf(10.4f,3.5); o/p - bbbbb3.5000
Flags
printf("%-10.4d\n", 25)
It causes the number to be printed as 0025bbbbbb. Thus, blanks are added to the right side. In the absence of a flag, it is printed as bbbbbb0025.
+ Indicates that i number is printed using a sign character (+ or ). printf("%+d\n", -25);>>> -25 printf("%+d\n", 25); >>> +25
# to display the output in another form Printf(%-9x,i); if i== 7c, it prints 0x7c
Escape Sequence
\a Alert - Produces a beep or flash; the
of next page.
\n New line - Moves the cursor to the
\\ - Prints \\
\" - Prints "
%% Prints %.