C++ Data Types
double floating point
[Identify the data type] 1.7e308
Integer
[Identify the data type] 22
floating point
[Identify the data type] 3.4e38
character
[Identify the data type] M
Boolean
[Identify the data type] True
primitive data type
[data type] built-in or predefined and can be used directly by the user to declare variables
user defined data type
[data type] A data type that a user can define by making it a subclass of a standard type or creating a type that behaves as an object.
integer
[primitive data type] All whole numbers (both positive and negative) and zero.
character data type
[primitive data type] keyword: CHAR
double floating point data type
[primitive data type] keyword: DOUBLE requires 8 bytes of memory space
floating point data type
[primitive data type] keyword: FLOAT requires 4 bytes of memory space
integer
[primitive data type] keyword: INT
void data type
[primitive data type] represents a valueless entity
integer
[primitive data type] requires *4 bytes of memory space* and ranges from -2147483648 to 2147483648
character data type
[primitive data type] requires 1 byte of memory space and ranges -128 and 127 or 0 to 255
boolean data type
[primitive data type] used for storing boolean of logical values
character data type
[primitive data type] used for storing characters characters: any letter (a..zA..Z) numeral (0-9) any other symbol including SPACE
double floating point data type
[primitive data type] used for storing double precision floating point value or decimal values
floating point data type
[primitive data type] used for storing single precision floating point values or *decimal values*
void data type
[primitive data type] used for those function which does not return a value
void data type
[primitive data type] without any value
variable
[user-defined data type] also called IDENTIFIERS
variable
[user-defined data type] defined by the user and are given initial values
variable
[user-defined data type] provides us with named storage that our program can manipulate
variable
[user-defined data type] symbol used in a program that stands for a value or data stored in a computer memory
variable declaration
a typical variable declaration is of the form
cin
asks for an input from the user ex: cin >> yourname;
boolean variable
can store either *True or False* keyword: BOOL
how to declare a variable
datatype variablename; *[do not forget to put the semicolon]* ex: int marks; char sex; bool name1; float name2;
info
each variable in C++ has a specific type which determines the size and layout of the variables memory; the range of the value that can be stored with that memory; and the set of operations that can be applied to the variable
how to declare a variable
in C++ strings are not a built-in data type; whenever we want to use and manipulate strings we must add the necessary preprocessor directives #include <string> using namespace std;
data type
indicates the type of data that can be stored in a field
primitive data types
integer character boolean floating point double floating point valueless or void wide character
info
name of variable can be composed of letter/digit and underscore character. *It must begin with either a letter or an underscore,
cout
outputs what is within the statements ex, cout << "hello" << endl;
variable declaration
the form that introduces a new variable name and its data type in a program
variable declaration
type variable_name; type variable1_name; variable2_name; variable3_name;