I am coding a very simple program in C but I keep getting wrong answers to calculations that I am doing. The final output that I want needs to have no decimal places so I am using int
as the data type even though the answer will not be an integer. Here is the code:
int numberOfInches = (100/254)*101;
I either get the answer 0 if I use int
as the data type or crazy long numbers if I try using float
or double
. Any ideas on what I am doing wrong?