Professional Documents
Culture Documents
CPL Prelims Finals
CPL Prelims Finals
HISTORY OF COMPUTERS
Mark 1
Schickard’s Calculating Clock
o 1944
o First gear-driven calculation machine o Special step in computer history
o Got little publicity because Schickard o First automatic digital computer in the
died in bubonic plague world
o Built during the World War II o Only in the minds of advance research
o First computers – designed for a specific scientists
task – extremely slow o Will be under artificial intelligence (AI)
o Relied on vacuum tubes and magnetic o Operations which requires low human
drums intelligence
o Parallel Processing - power of CPU’s
can be used side by side
o Will be more powerful than those under
Second Generation (1956 – 1963)
central processing
o Make use of transistors invented by Bell o Advances in super conductor technology
Telephone laboratories will greatly improve speed of info traffic
o Had many of the same components as
modern-day computers
o Had printer, tape or disk storage,
operating systems, stored programs,
memory
o More reliable and solid in design
__________
*
Who is the mathematician who proposed the
ALU concept in 1945 and design the parts of
CPU
John Von Neuman
CPL – MIDTERMS - FINALS IDE – Integrated Development Environment
NUMBER SYSTEMS
Three Stages of Developing a Computer
1. Binary – 0,1 – base 2 Program
2. Decimal – 0-9 – base 10
1. Creating
3. Octal – 0-7 – base 8
2 Main stages:
4. Hexadecimal – 0-9, A-F – base 16
Designing a program
A = 10 D = 13 Physically creating the program
B = 11 E = 14 - Has to be entered into the computer
C = 12 F = 15 - filename.cpp
2. Compiling
FLOWCHARTING - Converts source code to instructions
for the computer to run
Terminal (Start/End) - Stores these as executable file (.exe)
3. Running
Arrow
Input/Output Linking
2. Identifiers
INTRO TO C++ PROGRAMMING - Sequence of one or more
letters/digits/underline symbol
ANSI-C++ - Length not limited
(for some compiler: only first 32
- Published: November 1997
characters are significant)
Compilers – editors specifically tailored for - Spaces/marked letters are not part
C++ programs - Should always begin with a letter
- Can also begin with _ but usually for Declaring Variables
reserved external links
- Stating data-type and variable name
- Never begin with a digit
- Variables with same data type can be
- Cannot match any keyword of C++
grouped together
(variable names separated by
commas)
(semicolon to terminate declaration)
Variables - Variable may be assigned with initial
value
- Basic data objects manipulated in the
program 3. Data-types
- Can take on any value while program Computer’s memory is organized in bytes
is running Bytes: minimum amt of memory that we can
- Initialized before use (random number manage
or 0)
- Must be declared int the declarations
list
- Type is specified:
o char (hold single letter)
o int
o float (with decimal points)
o etc
Variable Names
- Up to 31 characters
- A – Z or a – z (case sensitive)
- 0 – 9 (but not as first character)
- Underscore (but not as first character)
- Generally better sticking to lower case
- Must not be a C++ keyword Signed/Unsigned
- Used to specify integer data type
(range)
C++ keywords - Default: signed
Declarations:
Constants
- Can declare constants with specific
type as you would with a variable
Integer Numbers
- Identify integer decimal places
-
-
- Allows use of octals and hexadecimals
(octal: precede with 0)
(hexadeci: precede with 0x) < Less than
>= Greater than or equal
Floating Point Numbers
<= Less than or equal
- Expresses numbers with decimals
and/or exponents Logic Operators
- e (“ten at the Xth height”) ! Not
&& And
Characters and Strings || Or
- Escape codes:
Conditional Operator
?:
condition ? result1 : result 2
- If true – will return result1
- If false – will return result2
Bitwise Operators
4. Operators
= assignment operator
Order of Precedence
Arithmetic Operators
+ Addition
- Subtraction
* Multiplication
/ Division
% Module (obtain remainder)
- // new style
- /* old style */
COMMUNICATION THROUGH
CONSOLE
# - are directives for the preprocessor; are not - Basic interface of computers
executable, but indications - Set composed of the keyboard (input)
and the screen (output)
#include Directive
iostream C++ library:
- Tells compiler’s preprocessor to
include - cin (input)
- cout (output)
#define Directive - cerr and clog (designed to show error
- Used to define an identifier and a messages)
string that will be substituted for the Output (cout)
identifier each time it is encountered
in the source file - used in conjunction with <<
- << (insertion operator) : inserts the
data
Function Prototype - “” : for constant string of characters
- cout << “the sentence”;
- Provides compilers with name and - \n or endl : line break
arguments of the function
- Must appear before function is used Escape sequences
if Statements statements 3;
if (expression) }
{ statement1; else
statement2; {
statement_last; statements 4; }