Monday, March 30, 2020

c program to multiplay two numbers

C Program to Multiply two number


#include 
int main()
{
    double a, b, product; // Initialization
    printf("Enter two numbers: "); //ask to user enter two numbers
    scanf("%lf %lf", &a, &b);  // storing values 
 
    // Calculating product
    product = a * b;

    // Result up to 2 decimal point is displayed using %.2lf
    printf("Product = %.2lf", product);
    
    return 0;
}

Output

Enter two numbers: 3.4
5.10
Product = 8.5

How program is work ?

  • In this program, the user is asked to entered two number which is stored in the variables a and 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);
Happy Coding

0 comments:

Post a Comment

Recent Posts