How does a C program to multiply two floating-point numbers work?

multiply integers


Courtesy: Programiz.com 


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.

Comments

Popular posts from this blog

C program to read and display book information using structure

Function prototype and definition

Actual and Formal Parameters