Write a C program to multiply two floating point numbers and print the result. In this example, we declare two floating point numbers and calculate the product of those two.
#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); }
This C program allows entering two floating point numbers and displays the multiplication result.
#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
In this C example, the multiplicationofTwo function accepts two floating point numbers and returns the product or multiplication of them.
#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