Hi! Today we will discuss Data type modifiers and Unary operators.
Data type Modifiers-
There are basically 4 datatype modifiers in C++-Signed,Unsigned,lond and short.
As the name suggests, it modifies the basic datatypes and change their meaning to fit them in various situations precisely.All data types can be modified using datatype modifiers except void.For eg-
unsigned int a;(It can store of positive integer which are not in range with normal integer datatype).
The opposite is the function of signed int.
Now long and short datatype modifiers change the amount of memory space given to a particular variable of that data type.
for eg- long int will be given 4 bytes space in memory whereas int is of 2 bytes(in turbo c++).
We can use these datatypes to make our program more precise which you will experience with time.
There are Unary operators like -,++,-- in c++;
++ or -- operators are used to increment or decrement the value stored in a variable by one.These can be used before and after the operands to specify different work.eg-
int a=10;
b=++a;
b=a++;
In both the cases the value of a is incremented by 1.In first case , the value of a is incremented first and then it is assigned to b,whereas in second case the value of a is assigned to b first and then the value of a is incremented.The value of b in both the cases will be 11 and 11 respectively and value of a after both the statements will be 12.
This is for today but you can try to solve basic programming problems alongside learning these basic concepts to make your strong hold on the language. There are many online platforms , like codechef , where you can start coding.
Thanks for reading.
Data type Modifiers-
There are basically 4 datatype modifiers in C++-Signed,Unsigned,lond and short.
As the name suggests, it modifies the basic datatypes and change their meaning to fit them in various situations precisely.All data types can be modified using datatype modifiers except void.For eg-
unsigned int a;(It can store of positive integer which are not in range with normal integer datatype).
The opposite is the function of signed int.
Now long and short datatype modifiers change the amount of memory space given to a particular variable of that data type.
for eg- long int will be given 4 bytes space in memory whereas int is of 2 bytes(in turbo c++).
We can use these datatypes to make our program more precise which you will experience with time.
There are Unary operators like -,++,-- in c++;
++ or -- operators are used to increment or decrement the value stored in a variable by one.These can be used before and after the operands to specify different work.eg-
int a=10;
b=++a;
b=a++;
In both the cases the value of a is incremented by 1.In first case , the value of a is incremented first and then it is assigned to b,whereas in second case the value of a is assigned to b first and then the value of a is incremented.The value of b in both the cases will be 11 and 11 respectively and value of a after both the statements will be 12.
This is for today but you can try to solve basic programming problems alongside learning these basic concepts to make your strong hold on the language. There are many online platforms , like codechef , where you can start coding.
Thanks for reading.
Comments
Post a Comment