In this post, let see how to print two float numbers using C language. This program is useful for school & college students and those who are learning the C language by themselves.
Without any delay, let’s write the “C Program to Multiply two floating-point numbers“.
#include <stdio.h>
int main() {
// define the variables
double x, y, ans;
// print about the program
printf(" -- Multiply two float numbers -- \n");
// get the value of x and y
printf("Enter x: ");
scanf("%lf", &x);
printf("Enter y: ");
scanf("%lf", &y);
// multiply the values
ans = x * y;
// print the answer with two decimals
printf("The Answer is: %.2lf", ans);
return 0;
}Please go through the comments in the above program to understand the functionality.
A sample output of the above program is:
You can also read the useful program here “C Program to print Odd numbers from 1 to N!“
