I'm learning c via a guide book and i am enjoying it. However, there is one question that i am stuck.
The question is:
"Write a program that when writing number "x" and number "y", the program shows how much % of x is in y."
"The answer should be 64 % when x = 54 and y = 84"
Obviously, 54 / 84 = 0.64... * 100, which is about 64 %. However, when I run my program it shows 84.689699. I tested without the "*100" but nothing. It shows 0.84689699...
Is my program wrong or is it a problem of the compiler or something? I am a beginner and it would be very helpful if someone tells me what is wrong.
PS: I use atom.io and gcc-compiler
#include <stdio.h>
int main(void)
{
double vx;
double vy;
printf("Enter the 1st number : "); scanf("%f" , &vx);
printf("Enter the 2nd number : "); scanf("%f" , &vy);
printf("\a\n\nx is %f of y" , vx / vy * 100);
return 0;
}