M3S2 Part 2 Flashcards
are built-in or predefined data types and can
be used directly by the user to declare variables.
Primitive Data Types
Primitive data types available in C++ are:
Integer Double Floating Point
Character Valueless or Void
Boolean Wide Character
Floating Point
are used
with the built-in data types to
modify the length of data that a
particular data type can hold.
Datatype Modifiers
Data type modifiers available in
C++ are:
Signed
Unsigned
Short
Long
the data type used for storing (+/-) whole numbers
Integer 4 bytes
the data type used for storing characters
Character 1 byte
the data type used for storing logical values
Boolean
A
boolean variable can store either
true or false
the data type used for storing single precision floating
point values or decimal values
Floating Point 4 byte
the data type used for storing double
precision floating point values or decimal values.
Double Floating Point 8 byte
the data type that represents a valueless entity or without any value.
void
It is used for those function which does not returns a value.
void data type
this data type is also a character data type but this
data type has size greater than the normal 8-bit datatype.
Wide Character
2 or 4 bytes
wchar_t.
char name variable can store up to how many character inputs?
20
The other way to initialize variables is done by enclosing the initial value between parentheses ().
constructor initialization
3 places in a C++ program where variables can be declared:
- outside of all functions
- inside the functions
- in the declaration of a formal parameter of a function.
Outside of all functions, including the main() function
may be used by any part of the
program.
global
Inside the function
may be used only by statements that are also in
the same function.
local
is any expression that has a fixed value.
constant
draw constant diagram
constant
- numeric
* integer
* real - character
* single character
* string
A character is enclosed between what
single quotes
contains a series of characters enclosed by
double quotation.
String constant
are specified as numerical (whole number)
constants without fractional components. No need to write
quotes (“) to express a numerical constant.
Integer numbers
require the use of decimal point
followed by the number’s fractional component. It may include a
decimal point, an e character or both.
Floating-point constants
you can declare constants with a specific
type in the same way as you would do with a variable
With the const keyword