编写一个 C 程序来乘以两个浮点数并打印结果。在此示例中,我们声明两个浮点数并计算它们的乘积。
#include <stdio.h>
int main()
{
float first = 11.7f;
float second = 12.2f;
float third = first * second;
printf("\nProduct of two Floating Point Numbers = %.2f\n", third);
}

此程序允许输入两个浮点数并显示乘法结果。
#include <stdio.h>
int main()
{
float first, second;
printf("Enter the First = ");
scanf("%f", &first);
printf("Enter the Second = ");
scanf("%f", &second);
float third = first * second;
printf("Product of two Floating Point Numbers = %.2f\n", third);
}
Enter the First = 23.98
Enter the Second = 43.67
Product of two Floating Point Numbers = 1047.21
Enter the First = 12.59
Enter the Second = 125.987
Product of two Floating Point Numbers = 1586.18
在这个示例中,multiplicationofTwo 函数接受两个浮点数并返回它们的乘积。
#include <stdio.h>
float multiplicationofTwo(float a, float b)
{
return a * b;
}
int main()
{
float first, second;
printf("Enter the First = ");
scanf("%f", &first);
printf("Enter the Second = ");
scanf("%f", &second);
float third = multiplicationofTwo(first, second);
printf("Product of two Floating Point Numbers = %.2f\n", third);
}
Enter the First = 22.9
Enter the Second = 44.56
Product of two Floating Point Numbers = 1020.42