In this example, user is asked to enter two float numbers and the program stores the entered values into the variable num1 and num2. The program then multiplies entered numbers and display the product as output.
#include <stdio.h>
int main() {
double a, b, answer;
printf("Enter first number: ");
scanf("%lf", &a);
printf("Enter second number: ");
scanf("%lf", &b);
answer = a * b;
// %.2lf displays number with maximum 2 decimal point
printf("Multiplication Is = %.2lf", answer);
return 0;
}
Output :
//Output :- 1
Enter first number: 10
Enter second number: 20
Multiplication Is = 200.00
//Output :- 2
Enter first number: 12
Enter second number: 5
Multiplication Is = 60.00
Ask anything about this examples