;

C Program to Multiply Two Numbers


Tutorialsrack 03/11/2019 C

In this C program, we will learn how to write a program to print the multiplication of Two Numbers. In this program, we are displaying the message using printf function and read the input taken from the user using scanf function.

Here is the code of the program to print the multiplication of Two Numbers.

Code - C Program to Multiply Two Numbers
/*C Program to Multiply Two Numbers*/
#include <stdio.h>
int main()
{
    double firstNumber, secondNumber, product;
    printf("Enter two numbers: ");
    // Stores two floating point numbers in variable firstNumber and secondNumber respectively
    scanf("%lf %lf", &firstNumber, &secondNumber);  
 
    // Performs multiplication and stores the result in variable productOfTwoNumbers
    product = firstNumber * secondNumber;  
    // Result up to 2 decimal point is displayed using %.2lf
    printf("Product of two numbers = %.2lf", product);
    
    return 0;
}
Output

Enter two numbers: 20
5
Product of two numbers = 100.00
--------------------------------
Process exited after 3.82 seconds with return value 0
Press any key to continue . . .


Related Posts



Comments

Recent Posts
Tags