Professional Documents
Culture Documents
Villamor
OPERATION ON NUMBER
10
Binary Addition + 1
------
11
1 1 1 1 1
1 1 1 1 0 1
+ 1 0 1 1 1
1 0 1 0 1 0 0
64 32 16 8 4 2 1
64 + 16 + 4 = 84
OPERATION ON NUMBER
10
Binary Subtraction - 1
------
1
1
0 10 10
1 0 0 1 1 1
- 1 1 1 0 1
0 0 1 0 1 0
Binary Multiplication
1 0 1 1 1
x 1 0 1 0
-------------------------------------------
0 0 0 0 0
1 0 1 1 1
0 0 0 0 0
1 0 1 1 1
1 1 1 0 0 1 1 0
128 64 32 16 8 4 2 1
128 + 64 + 32 + 4 + 2 = 230
Binary Division
11 1
110 101010
110
10 01
110
01 10
110
0
SIMPLE CONTROL STRUCTURES
A program is usually not limited to a linear sequence of
instructions. During its process it may bifurcate, repeat code
or take decisions. C++ provides control structures that serve
to specify what has to be done by our program, when and
under which circumstances.
Character: Character data type is used for storing characters. Keyword used for
character data type is char.
Boolean: Boolean data type is used for storing boolean or logical values. A boolean
variable can store either true or false. Keyword used for boolean data type is bool.
Floating Point: Floating Point data type is used for storing single precision floating
point values or decimal values. Keyword used for floating point data type is float.
Double Floating Point: Double Floating Point data type is used for storing double
precision floating point values or decimal values. Keyword used for double floating
point data type is double.
void: Void means without any value. void data type represents a valueless entity.
Void data type is used for those function which does not returns a value. void.
String Types
The string type is used to store a sequence of characters (text). This is
not a built-in type, but it behaves like one in its most basic usage.
String values must be surrounded by double quotes:
Example
string greeting = "Hello";
cout << greeting;
To use strings, you must include an additional header file in the source
code, the <string> library:
Example
#include <string>
string greeting = "Hello";
cout << greeting;