Hi,
I have the following program where i want the final result to show decimal numbers. As far as i know, %f is used to do so, but the answer is showing as 0.00000. Can someone help me sort out this problem please??
I have the following program where i want the final result to show decimal numbers. As far as i know, %f is used to do so, but the answer is showing as 0.00000. Can someone help me sort out this problem please??
Rich (BB code):
void main()
{
int a,b,c,d;
printf ("This is a calculator that let you enter four integer numbers and use them to work: (a*b)/(c+d) \n\n");
printf ("Enter number a: ");
scanf ("%d",&a);
printf ("\n\n(%d *b)/(c+d) \n\n",a);
printf ("Enter number b: ");
scanf ("%d",&b);
printf ("\n\n(%d * %d)/(c+d) \n\n",a,b);
printf("Enter number c: ");
scanf ("%d",&c);
printf("\n\n(%d * %d)/(%d +d)\n\n",a,b,c);
printf("Enter number d: ");
scanf ("%d",&d);
printf("\n\n(%d * %d)/(%d + %d)\n\n",a,b,c,d);
printf("The answer of (%d * %d)/(%d + %d) is %f",a,b,c,d, (a*b)/(c+d));
}