How I define a unit of measure in the value of the variable

Asked

Viewed 43 times

1

I have a question asking that I calculate the volume value of an oil can, and thinking about it I will use float. How do I place a unit of measure, for example the variable altura = 50cm.

1 answer

2


It does not, it is the problem of the application to deal with this kind of thing, you establish which unit is manipulating, the code understands units of some, what this thing only the programmer knows, the code does not.

It’s even possible to create some sophisticated mechanism to deal with it, but in C it doesn’t pay.

So put 50 in altura and be aware that are centimeters.

  • show understood , but if it is a code that really needs to inform the unit I can put in the comments right?

  • You can, of course, or you must.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.