i am a beginner to C++ , jus started taking a course on it. I was trying to create a program where you can enter strides in first minute of running, strides in last minute of running, and time ran ( hours, minutes) and using an average number of strides per minute the program gives you your total distance run. Using 50 stides in first minute, 70 stides in last minute , and 1hour 30 minutes for time, the program outputs 60 minutes for my average stride rate but 3.1145e-007 for total distance ran. I cant find the problem, any help would be greatly appreciated. here is the code i am using
you've given no values to s1, s2 totalStrides etc before using them in functions and calculations. 3.1145e-007 means 3.1145 to the power of -7, and evaluates to roughly zero
thanks for the advice buthow do i go about fixing this? if i have to rearrange everything what order should it go in?
i tried this rearrangement but did not work either so im not sure if that is what you mean.
I think you almost got it there! One variable (totalMinutes) is still uninitialized though. You are forgetting to call your function totalMinutes() to find totalMinutes before calculating totalStrides.
It may be legal to use the same name for the variable totalMinutes and the function totalMinutes(), but I think it's asking for trouble (or at least confusion). I'd recommend renaming one of them.
thanks for the help, it got it working. i changed the name of the function as you suggested but i think the problem was as you said, i was forgetting to call the function .