working with integer


this is my first time programming so i still have a lot to learn,
i have done the basic arduino tutorials, the thing is i dont really get what you do with “int” and how to use it.

do you give a name to a value with int so you can type the name instead of the number ? (int name = 10)


The "int" tells the compiler of what 'type' a variable is. "int" stands for integer. In case of the microcontroller used here, "int" also implies that the storage capacity of a variable declared as "int" is 2 bytes (or 16bit). It also tells you that the number stored is 'signed', otherwise it would be "unsigned int...".

Before I tell you too many wrong things, have a look at: "" and "Data Types".

The whole purpose of variables ( such as "int name = 10;" ) is to use them by name, to manipulate them later. If you just write "10" everywhere, you loose flexibility as the running program cannot change that later.

Tight flexibility is preferable.

There’s always Ruby, if you think C is too hard. Now we just need a microcontroller that can interpret Ruby.

And for people who are literate, there’s the official book about C: The C Programming Language by Kernigan & Ritchie. That’s a very information-dense but surprisingly easy-to-read introduction to C.

Surprisingly, it’s not! I bought it, took about ten months to plough through it, falling asleep on the train with it more often than not, and when I finished it felt like such a huge weight off my shoulders, yet had contributed nothing except more confusion about that language than I had before.

But that’s not pertinent to this thread, so I’m not sure why you brought it up.