Write a C Program to multiply two floating-point numbers.
In this Article, you will learn how to multiply two floating-point numbers.
A prime number is a natural number greater than 1 that has no positive
divisors other than 1 and itself. In other words, a prime number is only
divisible by 1 and itself. A number that is not prime is called a composite
number. To check whether a given number is prime or not, we need to check if
it has any divisors other than 1 and itself.
Here's a C program to multiply two floating-point numbers:
#include<stdio.h>
#include<conio.h>
void main()
{
float num1, num2, result;
// Input the first floating-point number
printf("Enter the first floating-point number: ");
scanf("%f", &num1);
// Input the second floating-point number
printf("Enter the second floating-point number: ");
scanf("%f", &num2);
// Multiply the two numbers
result = num1 * num2;
// Display the result
printf("Result: %f\n", result);
}
- We prompt the user to enter the first floating-point number using printf, and then we read the input using scanf and store it in the variable num1.
- Similarly, we prompt the user to enter the second floating-point number, read the input using scanf, and store it in the variable num2.
- Next, we perform the multiplication of the two input numbers and store the result in the variable result.
- Finally, we display the result using printf, showing the product of the two floating-point numbers.
When you run this program, it will ask you to enter two floating-point numbers, and it will display their product as the output.
Output: