Download Our Mobile App
As explained in the variables chapter, a variable in C must be a specified data type, and you must use a format specifier inside the printf() function to display it:
The data type specifies the size and type of information the variable will store.
In this tutorial, we will focus on the most basic ones:
There are different format specifiers for each data type. Here are some of them:
You have probably already noticed that if you print a floating point number, the output will show 6 digits after the decimal point:
If you want to remove the extra zeros (set decimal precision), you can use a dot (.) followed by a number that specifies how many digits that should be shown after the decimal point: