C Program to Multiply two Floating Point Numbers

Hello coders, in this post we will how to write C Program to Multiply two Floating Point Numbers. This is a very basic C program.

As you already know that this site does not contain only c programming solutions here, you can also find the solution for other problems. I.e. Web Technology, Data StructuresRDBMS ProgramsJava Programs Solutions,  Fiverr Skills Test answersGoogle Course AnswersLinkedin AssessmentLeetcode Solutions, and Coursera Quiz Answers.

C Program to Multiply two Floating Point Numbers
C Program to Multiply two Floating Point Numbers

if you want to learn C programming free of cost please visit:

C Program to Multiply two Floating Point Numbers

#include <stdio.h>
int main(){
   float num1, num2, product;
   printf("Enter first Number: ");
   scanf("%f", &num1);
   printf("Enter second Number: ");
   scanf("%f", &num2);

   //Multiply num1 and num2
   product = num1 * num2;

   // Displaying result up to 3 decimal places. 
   printf("Product of entered numbers is:%.3f", product);
   return 0;
}

Output

Enter first Number: 18.948
Enter second Number: 67.65
Product of entered numbers is: 1281.8322

C Program to Multiply two Floating Point Numbers using function

#include <stdio.h>
/* Creating a user defined function product that
 * multiplies the numbers that are passed as an argument
 * to this function. It returns the product of these numbers
 */
float product(float a, float b){
    return a*b;
}
int main()
{
    float num1, num2, prod;
    printf("Enter first Number: ");
    scanf("%f", &num1);
    printf("Enter second Number: ");
    scanf("%f", &num2);

    // Calling product function
    prod  = product(num1, num2);

    // Displaying result up to 3 decimal places.
    printf("Product of entered numbers is:%.3f", prod);

    return 0;
}
Enter first Number: 18.948
Enter second Number: 67.65
Product of entered numbers is: 1281.8322

Conclusion

I hope after going through this post, you understand how to write a C Program to Multiply two Floating Point Numbers, if there is any case program is not working and showing an error please let me know in the comment section.

Sharing Is Caring

Leave a Comment