# Program for Product of two numbers in C

## How to multiply two numbers in C?

We are going to learn to do the product of two numbers in C language. There are different ways to multiply numbers in C language. The most informative way to learn is by multiplying two floating point numbers in C as it includes both basic knowledge and a bit more knowledge due to floating points.

## Syntax:

General code to perform product of two numbers in C.
``` product = num1 * num2;
```

## Steps to multiply two number:

• Step 1: Start
• Step 2: Declare the variable num1=2, num2=4, product.
• Step 3: Read input num1 and num2 from the user or predefine it according to the need.
• Step 4: Multiply num1 and num2 and store the value in product.
• Step5: Display the number in the stdout console.
• Step 6: Program end.

## Working:

In these program we will learn to do the product of two number using various different ways.

## Example 1 :

A simple program where we will multiply two variables that are predefined.

Run
```#include<stdio.h>
int main() {
double num1=3.1, num2=4.2, product;
// Calculating product
product = num1 * num2;

//  displays number up to 2 decimal point
printf("Product = %.2lf", product);

return 0;
}```

### Output:

```Product = 13.02
```

## Example 2 :

Program where we will do the product of two floating point numbers given by the users.

Run
```#include<stdio.h>
int main() {
double num1, num2, product;
printf("Enter two numbers: ");
scanf("%lf %lf", &num1, &num2);

// Calculating product
product = num1 * num2;

// %.2lf displays number up to 2 decimal point
printf("Product = %.2lf", product);

return 0;
}```

### Input:

```Enter two numbers: 9.6
5.24```

### Output:

`Product = 50.30`

## Example 3 :

Program where we will multiply two floating point number in C using functions.

Run
```#include<stdio.h>
float multiply(float a, float b){
return a * b;
}
int main(){
float num1, num2, product;
printf("Enter the first Number: ");
scanf("%f", &num1);
printf("Enter the second Number: ");
scanf("%f", &num2);
product  = multiply(num1, num2);
printf("The Product of the numbers is : %.3f", product);
return 0;
}
```

### Input:

```Enter the first Number: 5.25
Enter the second Number: 6.1
```

### Output:

`The Product of the numbers is : 32.0255`

### Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

## Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others