C++ Constants, Variables, Data types,
Keywords C++ Programming Article
We're going to be learning about the constants the variables data types and the keywords in C++.
First we're going to begin with the constants as a name indicates a constant is an entity which doesn't change.
C++ Variables, Constants, Data types, Keywords | C++ Programming Article |
We have different types of constants.
For example, we have integer constants, which is an whole number for example, 44 or we have 86 or any whole number which is an integer constants.
And then we have floating-point constants.
For example, 12 point 2 3, you know a number with decimal values 34.5 3, etc.
So all these are floating point constants, then we have character constants, you know, for example a letter A or a letter B or a letter Z, you know character cut single character and a character constants is written in single quotes and then we have string constants which are written in double quotes.
For example Anil and we have any other string for example Ladd, you know, which is written in double quotes and which is a bunch of characters.
These are called string constants in computer memory.
Whatever we save the values will be stored in zeros and ones.
So this computer memory is divided into small small bits and small small bits a group to form bytes eight bits are group to form one byte.
So it's going to be 8 bit equal to one byte the values zeros and ones are stored in this bits 0 or 1.
So something like this and all of you know, that computer member has their own address.
For example, let's say this byte has address 1 2 3 4 5 say 7:8 and similarly.
This white is can contain its own entrance.
And when we store some values in our computer memory, you know, when we want to use that in our program, what we need to do is we need to refer this address or the location where our value is stored.
So to access the value stored in a memory by using its address is very difficult.
That's why what we're going to do is we're going to do a name to this memory location so that we can easily remember that and also we can easily refer that.
For example, let's give a new name called X to this byte.
So so this name given to this memory address or the name given to the memory location is called as a variable.
So a variable is nothing but the 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, you know, whenever we refer to that variable, for example, Y equal to 2 X, you know, let's assume that Y is another variable here the X will refer to whatever value which is stored in this variable or the memory location refer by this variable X.
Next is about that Data Types:
All of you know that you know, when we store some values in our memory locations, you know and give some name to them, you know, the compiler wants to know what type of data we are storing in that variable or the memory location.
The type of data stored in a variable is called data type.
We have integer data types which refer to the integer constants.
We have character data types which refers to character constants.
We have floating point:
We have boolean we have and one special data type is there which is called void, which is normally used with the functions just to indicate that a particular function is not going to return any values, you know, which we can alone later in the tutorials on the functions.
Our data type is nothing but what type of data is stored in a variable or a memory location.
We have integer floating-point character boolean, you know, which is true or false then void, you know, which is valueless datatypes.
And also we have some type modifiers which are used with a data types.
We have signed unsigned short and long type modifiers and these are used with the data types.
And this type modifiers are going to influence on the number of bytes to store a particular value.
For example, some compilers are going to take 2 bytes to store an integer value and you know, some compilers are going to take 4 bytes at something like that.
When we use this type modifiers, they're going to increase or decrease the bytes or memory taken to store that particular variable of that time.
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 going to store integer value in a memory location or in a variable.
We need to use the keyword int as the data type.
This int is a keyword for integers similarly.
We have float for floating then care for character then bull for boolean etcetera etcetera.
There are many keywords available in C++.
And for example, we have if you know whose meaning is already defined to the compiler we have four we have switch and many other.
The main thing is we can't use these keywords whatever keyword is that we can't use them with our variable name.
Here we have a variable name or the name given to the number location is called X and here we can't give a keyword here.
For example, I cannot write int here or I can't give a name into the memory byte.
Once again a constant is an entity which does not change.
We have integer floating-point character string constants.
Then our variable is a name given to a memory location in order to access that easily and then data type indicates.
What type of data is stored in variables and the keywords are the words whose meaning is already defined to the compiler and we can't use them as the variable names.
This is it guys.
This is about some information on the constants variables datatypes and keywords.
So I'm really sorry for that and thank you for Reading.
0 Comments