2. Datatypes in C++
◦ Data type refer to the kind of data to be stored in variable.
◦ There are two types of data type
◦ Fundamentals/Built in datatype.
◦ Derived datatype/user defined datatype.
3. Fundamentals datatype
◦ Fundamental data types are the data types which are predefined in the language and can be directly used
to declare a variable in C++.
Example are:
◦ Int ,float,char,double,bool etc.
Syntax:
◦ Datatype varible_name;
4. User defined datatype:
◦ Data types that are derived from fundamental data types are derived types. For example:
arrays, pointers, function types, structures, etc.
5. Data Type modifier in C++.
• As the name suggests ,these are used to modify primitive data type i.e int,char,float.
• They are used as a prefix to the primitive data types.
• These modifiers change the size and the type of values that a primitive data type can hold.
Examples are:
singed int, unsigned int, short int etc.
6.
7. Variables in C++
◦ Variables are containers for storing data values.
◦ Int -stores integers (whole numbers), without decimals, such as 123 or -123.
◦ double- stores floating point numbers, with decimals, such as 19.99 or -19.99
◦ char-Stores single characters, such as 'a' or 'B'. Char values are surrounded by
single quotes.
◦ string-stores text, such as "Hello World". String values are surrounded by double
quotes
◦ Bool-Stores values with two states: true or false.
8. Declaring variable and initializing
variable
◦ To create a variable, specify the type .
◦ Syntax; datatype varible_name;
◦ Example: int number;
Initializing a variable:
To create a variable, specify the type and assign it a value:
◦ Syntax; datatype varible_name=value;
◦ Example: int number=10;
10. Implantation:
• Checking size of datatype.
• Declaring variable.
• Initializing variable.
• Taking value from user.
• Putting invalid value in a
datatype