Example: This program will output the value of a variable as you initialize it.
What you must know first?
Different Class Specifiers in Turbo C:
Data Type Control String Definition Example
Char "%c" used for ouputting a 'W' or 'p'
letter or a symbol.
Char "%s" used for outputting two 'Yes!' or 'Pie'
letters or symbols.
int "%d" used for outputting integers. '56' or '12'
float/double "%f" used for outputting numbers '5.2648'
with decimal places.
Note: This Program will shows the difference between println and printf statement.
By using printf:
It is will ouput the number and some unnecessary zeros showing that it is a double/float specifier.
You can limit the variable's decimal places by adding a decimal point and a number to the control string. ex. " .2%f" will display a float number with 2 decimal places. You can change it to 3 or so on.
By using println.
It will output the value of the variable the way you exactly assigned it. No unnecessary zeros at so on.
No Response to "Java Tutorial #1"
Post a Comment