this is my first question here :)
I want a program that converts lighyears into kms. I defined a constant value for LIGHTYEARSINKM, but even if I just want to convert one lightyear in km, the compiler gives me a different value from the defined one.
For example if give the input 1, the output is 9460500135936.000000 (different from 9460500000000.000000)
What am i doing wrong?
Heres the code I wrote:
#include <stdio.h>
#define LIGHTYEARSINKM 9460500000000.000000
int main( void )
{
float lightyear;
float kilometer;
printf("Lightyears you want to convert into km:\n");
scanf("%f", &lightyear);
kilometer= lightyear * LIGHTYEARSINKM;
printf("%f lightyears are %f kilometer",lightyear,kilometer);
getchar();
return 0;
}