L01 Intro
L01 Intro
Introduction
Hardware
hardware - physical devices that make up computer equipment
computer - PC/mainframes/workstations
computer contains 5 main components
CPU - follows the instructions and performs calculations specified by the
program
input device - any device that allows outside world to communicate information
to the CPU
output device - any device that allows CPU to communicate information to the
outside world
main memory/primary memory/RAM - a list of addressable memory locations
that CPU can operate upon, not permanent
– bit - the least possible amount of information: 0 or 1
– byte - 8 bits
– memory location - single (indivisible) portion of memory that holds data
– address - number that identifies a memory location
secondary memory – memory that is used for keeping a permanent record of
information – disk/data CD/flash drive
2
Hardware Diagram
3
CPU Accessing RAM
4
Software
program – a sequence of instructions for computer to follow
system – to be used by other programmers
– operating system – allocates computer resources, launches other programs and
ensures they work properly
application – to be used by end-users
software - collection of programs
data - input to the program
running/executing program - performing program instructions on given data
languages
natural - language used by humans
high-level - language (close to natural) that is understood by humans, C++ is a high-
level language
machine (low-level) - list of instructions in binary format that a computer understands
0101 0001 1100 0010
code
source (high-level language)
object (machine language)
executable code - can run on computer
library – a collection of previously developed object code: input/output, math, etc.
compiler – a system program that translates high-level language into low-level language
linker - program that takes object code and produces executable code
5
Producing Executable Code
source code include files
(add1.cpp) (add1.h, iostream)
done by linker
link object
code with
check
object pre-compiled
file code routines from
add include unit for legal standard
(add1.o)
files syntax and libraries to
compile it into produce
an object standard executable
code code
libraries
7
C++ Popularity
C/C++ are possibly the most popular programming languages in use
today
most of operating systems (one of the largest and most complicated
pieces of software) is written in C or C++
source code for Microsoft Windows 7 contains 40 million lines of
mostly C/C++
source code for Linux Kernel (v.4.10.11) 18 million lines of
primarily C
8
C++ Program Layout
#include <iostream>
include directive - tells compiler int main() {
where to find certain items about
the program statement 1;
main part (main function) - contain
instructions for computer, starts and
// comment
ends with curly brackets: {} statement 2;
indiciates program start
9
First Program: helloWorld.cpp
include // displays a greeting
directive // Mikhail Nesterenko
// 8/25/2013 comments
#include <iostream>
output
statement
Rules of Programming
syntax - the principles of constructing (structuring) the program
legal program construct complies with syntactic rules
illegal violates
11