Data Types in c++ -(Day Five)

Data Types in C++ Data can be of any type. To store these data, we need different data types in c++

Data Definition Example
Character Anything enclosed in single quotes ‘ ’ ‘z’
Integer Number without fractions 6
Real Number with fraction 1.5
String Anything enclosed in “ ” “a”
C++ handles these data by providing different data types. Data types  means to identify type of data and associated operation of handling it.

data types in c++ Data types in c++ can be divided into two types –
  1. Fundamental – that are not composed of other data types.
  2. Derived – that are composed/derived from fundamental data types.
Fundamental Data Types can be further divided into –  
Data Types Bytes Required Used for Handling Example
int 2 Integer data 5, 39, -1917, 0
char 1 Character data ‘A’ , ‘a’
float 4 Fractional data 1473.910 (Normal Form), 1.473910E03 (Exponent Form)
double 8 Fractional data of larger range 87115.9504256
void Used as return type for functionsThat do not return value. Void function1();
  Built In Data Types – 
  • Array- is a c++ derived data type that can hold several values of same data type.
  • Functions- are small parts of a program, which are designed for specific use.
  • Pointers – is a variable that holds a memory address. The address is usually the location of another variable in memory. And if one variable contains the address of another variable, the 1st variable is said to point to the 2nd
  • Reference – is a aternative name for an object. It provides a alias for a previously defined variable.
  • Constant – are the objects, that never change their value throughout the program. A const int is equivalent to const only.
Derived data types in C++ User Defined Data Types :
  • Class – is a group of similar objects and the keyword used for class is ‘class’..
  • Structure – is a collection of variables of different data types referenced under one name and the keyword used for structure is ‘struct’.
  • Union – is a memory location, that is shared by two or more different variables, generally of different types at different times and the keyword used for union is ‘union’.
  • Enumeration – an alternative method foe naming integer constants and is often more convenient than const. The keyword used for enumeration is ‘enum’
   ]]>

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top