+ 2

Can someone correct this🤔

Instead of the result: Enter the first number: 1.6 Enter the second number: -2 Enter the third number: -1 Product = 3.2 #include <stdio.h> int main() { int a, b, c; int product; printf("Input the first integer: "); scanf("%lf", &a); printf("Input the second integer: "); scanf("%lf", &b); printf("Input the third integer: "); scanf("%lf", &c); product = a*b*c; printf("Product = %.2lf\n", product); } The result of my code is: Input the first integer: 1.6 Input the second integer: -2 Input the third integer: -1 Product = 0.00 Why is 0.00 in the product instead of 3.2?

4th Nov 2021, 6:37 AM
Im new
3 Respostas
+ 3
YVONIE CALICARAN Your entered input is a type of double or float because it contains decimal so you can't take float or double input as a int So you can use float or double like this: float a, b, c, product; scanf("%f", &a); scanf("%f", &b); scanf("%f", &c); product = a * b * c; printf("Product = %.2f\n", product);
4th Nov 2021, 8:34 AM
A͢J
A͢J - avatar
+ 6
Use `double` as data type for <a>, <b>, <c> and <product> variable rather than `int` double a, b, c, product;
4th Nov 2021, 7:00 AM
Ipang
+ 3
Thanks
4th Nov 2021, 7:03 AM
Im new