C Program to Multiply Two Floating-Point Numbers

C Program to Multiply Two Floating-Point Numbers

C program to multiply two floating-point numbers; Through this tutorial, we will learn how to multiply two floating-point numbers in the c program.

Algorithm to Multiply Two Floating Point Numbers

Use the following algorithm to write a program to multiply two floating point numbers; as follows:

  • Step 1: Start program.
  • Step 2: Read two numbers from user and store them into variables.
  • Step 3: Multiply two floating point numbers and store result in variable.
  • Step 4: Print multiply two floating point numbers.
  • Step 5: End program.

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;
}

The output of the above c program; as follows:

Enter first Number: 3.5
Enter second Number: 5.5
Product of entered numbers is:19.250

C Program to multiply two 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;
}

The output of the above c program; as follows:

Enter first Number: 5.5
Enter second Number: 6.5
Product of entered numbers is:35.750

Recommended C Programs

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *