About Me

Hello there! Before talking about qualifications and professional abilities, I would like to introduce myself. I am a Yuvraj Basnet and professional software developer and have been working in this field for 3 long years. I have finished my graduation from The University of Delhi on Computer Science Engineering I considered myself a reasonably experienced programmer with a particular interest in the human side of software development, computers are fascinating machine, but they're mostly reflection of the people using them. In the art of software development, studying code isn't enough; you have to study the people behind the software, too.

C++ Constant, Variables, Data types and Keywords


C++ Constant, Variables, Data types and Keywords

C++ Constant, Variables, Data types and Keywords

Hi this is Yuvraj from welearncode and welcome to the another tutorial on C++ programming. In this tutorial we are gonna be learning about the contants, 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 for example we have integer constant which is an whole number for example 44, 86 or any whole number which is an integer and then we have floating point constants for example 12.24, a number with decimal values and then we have character constant for example a letter 'A' or a letter 'b' etc. Character constant are always written in single quotes ('') and then we have string constant which are written in double quotes ("") for example "yuvraj". 

Now let us discuss variables- In computer memory whatever we save the values will be stored in 1's and 0's these computer memory is divided into small bits and these small bits are grouped to form bytes for example 8 bits are grouped to form one byte so it's gonna be 8 bit equals to one byte. The values 0's and 1's are stored in these bits (0,1) and all of you know that computer memory has their own address for example some byte has a address 1234567 and similarly some byte is gonna be contain it's own address and when we store some values in computer memory or when we want to use them in our program what we need to do is we need to refer the some address or the location where our value is stored and to access the value stored in a memory by using it's address is very difficult that's why what we gonna do is we are gonna give a name to this memory location so that we can easily remember that and also we easily refer that for example let's give a new name called x to byte. So this name given to the memory address or the name given to the memory location is called as a variables. A variable is nothing but the name given to a memory location in order to access it easily so whenever we give a name or create a variable in our program or whenever we refer to that variable for example y=3x 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 referred by this variable x. 

Now the next thing is about the data types all of you know that when we store some values in our memory locations and give some name to them the compiler wants to know what type of data we are storing in that variable or the memory location then the type of data stored in a variable is called data type. We have integer data types which refer to the integer constant, character data type which refers to character constants, floating point, Boolean, 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 gonna return any values. A data type is nothing but what type of data is stored in a variable or a memory location and also we have some type modifiers which are used with the data types like signed, unsigned, short, and long type modifier and these are used with the data types and 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 some compilers take 4 bytes. 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. 

Now 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 for, switch, many are there. The main thing is we can't use these keywords with our variable name in the above example the name given to the memory location is called x and we can't give a keyword here for example I can't write int there or I can't give a name int to the memory byte. 



  


Post a Comment

0 Comments