I just started learning C and I have a question about float...
i made a simple multiplying program:
#include<stdio.h>
#include<stdlib.h>
main()
{
float x;
float y;
float answer;
char xchar;
char ychar;
printf("Enter a number:\n");
gets(xchar);
x=atoi(xchar);
printf("Enter a second number\n");
gets(ychar);
y=atoi(ychar);
answer=x*y;
printf("%f x %f = %f\n",x,y,answer);
}
When I try to muliply decimal numbers, it will give me the answer but if the answer if supose to have a decimal point, it will only give the numbers that come before the decimal. like 5.33 x 2 will equal 10 and not 10.66