Weird coding question

So I’m working on an odometry code and after I already identified a variable (dM) vex told me that I needed a specifier for all declarations even though I already did. Did I miss something that I don’t realize or is there something I don’t know?

First of all, dM should be type “double” instead of “int” for when dR+dL is an odd number. I would also try initializing dM to a starting value:
double dM = 0;

Apart from this, you should put the equation inside the while loop that will run your odometry.

3 Likes

There are declarations and initializations. Declarations are where you specify the name and data type. Initializations assign an initial value to a variable. For most variables it is easier to combine the declaration and initialization and set the variable equal to 0 to start. This removes conflicts further down the road. You can also forward declare a variable in a header file so that you can access that variable in many separate files.

1 Like

That line of code needs to be inside a function, my guess is it isn’t.

3 Likes

thanks everyone!

(20 characters)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.