c printf float value
#include <stdio.h>
int main() {
float num = 3.14;
printf("The value of num is: %f", num);
return 0;
}
Explanation:
- #include <stdio.h>
: Includes the standard input-output library in the program.
- int main() { }
: The main function where the execution of the program begins.
- float num = 3.14;
: Declares and initializes a variable num
of type float
with the value 3.14
.
- printf("The value of num is: %f", num);
: Prints the value of num
using the printf
function with a format specifier %f
, which is used for printing floating-point numbers.
- return 0;
: Indicates the end of the main
function and returns an exit status of 0
, indicating successful execution of the program.