C Constants, variables, datatypes and keywords
Hi there !
In this tutorial we are gonna be learning about the constants, the variables, data types and the keywords in c. So first we are gonna begin with the constants.
As the name indicates a constant is an entity which doesn’t change. We have different types of constants.
We have integer constants which is an whole number, for example 44 or we have 86 or any whole number which is an integer constant.
We have floating point constants, for example 12.23, you know a number with decimal values, 34.53 etc etc. So all these are floating point constants.
We have character constants, for example letter a, or a letter b, or a letter z, are character constants, single character and character constants are written in single quotes.
We have string constants which are written in double quotes for example “boxmoonbabble” and we have any other string for example “Lad you know” which is written in double quotes and which is a bunch of characters. These are called string constants.
A variable is nothing its just a name given to a memory location in order to access it easily. So when we give a name or create a variable in our program, whenever we refer to that variable, for example
y = 500;
Here y is a variable and 500 is the value being assigned to that variable y.
The type of data stored in a variable is called data type. We have integer data types which refers to the integer constants, we have character data types, which refers to character constants, we have floating point, we have boolean, we have one special data type is there which is called void which is normally used with the functions.
So a data type is nothing but what type of data is stored in a variable or a memory location. So we have integer, floating point, character, boolean which is true or false then void you know which is value less data types. And also we have some type modifiers which are used with the data types, we have signed, unsigned, short and long type modifiers and these are used with the data types.
These type modifiers are gonna influence on the number of bytes to store a particular value for example some compilers are gonna take 2 bytes to store an integer value and you know some compilers are gonna take 4 bytes something like that. So when we use these type modifiers they are gonna increase or decrease the bytes or memory taken to store that particular variable of that type. All right, the next thing is about the keywords.
These keywords are nothing but the words whose meanings are already defined to our compiler. For example to indicate that we are gonna store integer value in a memory location or in a variable we need to use the keyword int as the data type. So this int is a keyword for integers similarly we have float for floating then char for character then bool for boolean etc.
So there are many keywords available in c. For example we have if whose meaning is already defined to the compiler, we have for, we have switch, and many are there. So the main thing is we can’t use these keywords as our variable name.
So this is it guys, this is about some information on constants, variables, data types and keywords. Thanks for reading !