num1
and num2
. The program then multiplies entered numbers and display the product as output.#include <stdio.h>
int main(){
float num1, num2, product;
printf("Enter first Number: ");
scanf("%f", &num1);
printf("Enter second Number: ");
scanf("%f", &num2);
//Multiply num1 and num2
product = num1 * num2;
// Displaying result up to 3 decimal places.
printf("Product of entered numbers is:%.3f", product);
return 0;
}
Enter first Number: 54.23
Enter second Number: 73.61
Product of entered numbers is:3991.870
product()
that multiplies the numbers that we are passing to it during function call. This function returns the product of these numbers.#include <stdio.h>
/* Creating a user defined function product that
* multiplies the numbers that are passed as an argument
* to this function. It returns the product of these numbers
*/
float product(float a, float b){
return a*b;
}
int main()
{
float num1, num2, prod;
printf("Enter first Number: ");
scanf("%f", &num1);
printf("Enter second Number: ");
scanf("%f", &num2);
// Calling product function
prod = product(num1, num2);
// Displaying result up to 3 decimal places.
printf("Product of entered numbers is:%.3f", prod);
return 0;
}
Enter first Number: 36.12
Enter second Number: 45.72
Product of entered numbers is:1651.406