There is a question in my text C Primer + that wants you to convert your age into seconds and it tells you that there are 3.156x(10 to the power of seven) seconds in a year. So I came up with the following program which produces the same output for every age. From that I a can see that I messed up. Can anyone see where I went wrong? My guess is that a long double isn't big enough to hold that no. of seconds.
Code:/* convert age from years to seconds */ #include <stdio.h> int main(void) { int age; long double seconds_age; seconds_age = age * 3.156e7; printf("Enter your age: "); scanf("%d", &age); printf("%d years is %lf seconds", age, seconds_age); }