I am very new to programming (a whole week now!) and I picked up a copy of C primer plus 5ed. I have been doing pretty well so far considering I have nobody to ask for clarification. I am on an exercise that wants me to display age in seconds. Everything is working except the math. I think it is an issue with data types, but I have no idea. If anyone can point me in the right direction I would appreciate it.
On a side note, I got this book because it was recommended. Does anyone have any other recommendations for someone just learning programming?
Here is what I have so far. It is giving an answer that is way to high.
Code:
// tells age in seconds
#include <stdio.h>
int main(void)
{
int age;
printf("how old are you?\n");
scanf("%d", &age);
printf("no, you are %d.\n", age * 3.156e7);
return 0;
}
Oh yeah, I'm running a Linux box if that matters.