In this article, the product of two floating-point numbers entered by the user is calculated and printed on the screen. To understand this example, you should have the knowledge of the following C programming topics:

C Variables, Constants and Literals
C Data Types
C Input Output (I/O)
C Programming Operators
Program to Multiply Two Numbers
#include <stdio.h>
int main() {
double a, b, product;
printf("Enter two numbers: ");
scanf("%lf %lf", &a, &b);
// Calculating product
product = a * b;
// %.2lf displays number up to 2 decimal point
printf("Product = %.2lf", product);
return 0;
}
Output
Enter two numbers: 2.4
1.12
Product = 2.69
In this program, the user is asked to enter two numbers which are stored in variables a and b respectively.
printf(“Enter two numbers: “);
scanf(“%lf %lf”, &a, &b);
Then, the product of a and b is evaluated and the result is stored in product.
product = a * b;
Finally, product is displayed on the screen using printf().
printf(“Product = %.2lf”, product);
Notice that, the result is rounded off to the second decimal place using %.2lf conversion character.
Types of Sorting Algorithms:
Additional Reading
- SEO Practices Everyone Should Follow SEO Rules
- Complete Top SEO Checklist
- Yoast Seo Premium 15.2 Nulled – WordPress SEO Plugin
- Top 50+ SEO Interview Questions
- What is a Backlink? How to Get More Backlinks
READ MORE
If you found this post useful, don’t forget to share this with your friends, and if you have any query feel free to comment it in the comment section.
Thank you 😊 Keep Learning !