Programming Principles- Chapter 1
pixels
"picture elements" -tiny dots that form an image on the screen.
pseudocode
Algorithms can be described in natural language or _____________. -natural language mixed with some programming code.
zero
Another common source of runtime errors is division by
communication devices
Computers can be networked through _________ ______, such as a dial-up modem(modulator/demodulator), a DSL or cable modem, a wired network interface card, or a wireless adapter.
control unit; arithmetic/logic unit
The CPU has two components:
drives
devices used to operate a storage medium, such as a disk or CD. -reads data from the medium and writes data onto the medium.
manually
the resolution can be set
successful exit
the value 0 indicates that the program has terminated with a
left
to assign a value to a variable, you must place the variable name to the ______ of the assignment operator.
programming
to create (or develop) software.
compiler
translates the entire source code into a machine-code file, and the machine-code file is then executed.
compiler
translates the intermediate file into a machine-code file.
CD-R; CD-RW
two types of CD drives
nibble
4 bits are referred to as a
statement terminator (;)
Each statement ends with a
errors
Fix ____ from the top line and work downward.
silicon semiconductor chips
Like the CPU, memory is built on ______ ________ _____ that have millions of transistors embedded on their surface.
storage devices
Programs and data are permanently stored on ______ ______ and are moved, when the computer actually uses them, to memory, which operates at much faster speeds than permanent ______ _____ can.
idle
The CPU is ____ while waiting for data to be transferred from a disk or waiting for other system resources to respond.
hertz (Hz)
The unit of measurement of clock speed.
control unit
controls and coordinates the actions of the other components.
0
if the switch is off, the value is
runtime errors
input mistakes typically cause
{ }
opening and closing braces -denotes a block to enclose statement.
;
semicolon -marks the end of a statement
standard
using namespace std; -tells the compiler to use the standard namespace. -std is an abbreviation
header file
usually included at the head of a program. ex.) iostream in previous example
changed
variables are used to represent values that may be ____________ in the program.
empty
without programs, a computer is an ____ machine.
preprocessor directive
#include <iostream> -tells the compiler to include iostream library in this program, which is needed to support console input and output.
major hardware components
-Central processing unit (CPU) -Memory (main memory) -Storage devices (such as disks and CDs) -Input devices (such as mouse and keyboard) -Output devices (such as monitors and printers) -Communication devices (such as modems and network interface cards)
Major tasks of an operating system
-Controlling and monitoring system activities -Allocating and assigning system resources -Scheduling operations
main types of storage devices
-magnetic disk drives -optical disk drives (CD and DVD) -USB flash drives
rules of identifiers
-sequence of characters comprising letters, digits, and underscores -must start with letter or underscore, NOT a digit -cannot be a reserved word -can be any length, stop at 31
types of programming errors
-syntax errors -runtime errors -logic errors
1 pulse per second.
1 hertz equals _________
benefits of using constants
1) you don't have to repeatedly type the same value 2) if you have to change the constant value you only have to change it in a single location in source code. 3) descriptive constant names make the program easier to read.
byte
8 bits are referred to as a
redirection
<< is the ______ symbol
stream insertion operator
<< operator -sends a string to the console
main
A C++ program is executed from the ____ function.
4.7 GB
A DVD's storage capacity is
eight
A byte is composed of _____ bits.
volatile
A computer's memory (RAM) is a _____ form of data storage: information that has been stored in memory is lost when the system's power is turned off.
speed
A higher clock ______ enables more instructions to be executed in a given period.
empty
A memory byte is never _____, but its initial content may be meaningless to your program.
memory
A program and its data must be moved into the computer's ______ before they can be executed by the CPU.
mnemonic
A short descriptive word that represents each of the machine-language instructions. -assembly language uses this. ex.) to add numbers 2 and 3 add 2, 3, result
Python
A simple general-purpose scripting language good for writing short programs.
single
A small number such as 3 can be stored as a _____ byte.
several
A statement from the source code may be translated into _____ machine instructions
quotation marks
A string must be enclosed in ________ ______.
quotation marks
A string must be placed inside the __________ ______.
low-level language
Assembly language is referred to as ______ ______ because assembly language is close in nature to machine language and is machine dependent.
BASIC
Beginner's All-purpose Symbolic Instruction Code. -was designed to be learned and used easily by beginners.
BCBL (Basic Combined Programming Language)
C evolved from the B language, which evolved from the _____.
case-sensitive
C++ is ____________. -Misspelling names is a common error made by new programers.
syntax
C++ own rules of grammar.
Bjarne Stroustrup
C++ was developed by
compact disc
CD stands for
one
CPUs were originally developed with ____ core.
COBOL
Common Business Oriented Language. -used for business applications.
less
Compared to CPU chips, memory chips are ____ complicated, slower, and ____ expensive.
digital versatile disc; digital video disc.
DVD stands for
C
Developed at Bell Laboratories. -combines the power of an assembly language with the ease of use and portability of high-level language.
Java
Developed by Sun Microsystems, now part of Oracle. -It is widely used for developing platform-independent Internet applications.
syntax errors; compile errors
Errors that are detected by the compiler are called
FORTRAN
FORmula TRANslation. -popular for scientific and mathematical applications.
programming; documentation
Good _________ and proper ___________ make a program easy to read and help programmers prevent errors.
comments
In a long program, you should also include _________ that introduce each major step and explain anything that is difficult to read.
megahertz (MHz)
In the 1990s, computers measured clock speed in _______.
summary
Include a _______ at the beginning of the program to explain what the program does, its key features, and any unique techniques it uses.
two
Indent each subcomponent or statement ____ spaces more than the construct within which it is needed. ex.) << 3 + 4 * 4;
concise
It is important to make comments ______ so that they do not crowd the program or make it difficult to read.
popular IDEs
Microsoft Visual C++, Dev-C++, Eclipse, and NetBeans
popular operating systems
Microsoft Windows, Mac OS, and Linux.
Ada
Named for Ada Lovelace, who worked on mechanical general-purpose computers. -developed for the Department of Defense and is used mainly in defense projects.
Pascal
Named for Blaise Pascal, who pioneered calculation machines in the seventeenth century. -simple, structured, general-purpose language primarily used for teaching programming.
security
OS is responsible for ____, ensuring that unauthorized users and programs do not access the system.
machine
Programs written in ____ language are very difficult to read and modify.
C#
Pronounced "C Sharp." -hybrid of Java and C++ and was developed by Microsoft.
random access memory (RAM)
Since the bytes in the memory can be accessed in any order, the memory is also referred to as _____ _____ _________.
computer resources
The OS is responsible for determining what ________ ______ a program needs (such as CPU time, memory space, disks, and input and output devices) and for allocating and assigning them to run the program.
higher
The ____ the resolution, the sharper and clearer the image.
smaller
The _____ the dot pitch, the sharper the display.
gigahertz (GHz)
The clock speed of a computer is now usually stated in __________.
lost
The current content of a memory byte is ____ whenever new information is placed in it.
#
The directives start with ____ sign.
object file
The machine-code file is also known as an
RAM
The more ____ a computer has, the faster it can operate, but there are limits.
*
The multiplication operator in C++ is
multiple cores
To increase CPU processing power, chip manufacturers now produce CPUs that contain
multiprogramming, multithreading, and multiprocessing
To increase system performance, many of today's operating systems support such techniques as ______________, ____________, and _______.
transistors
Today's CPUs are built on small silicon semiconductor chips that contain millions of tiny electric switches, called ________, for processing information.
IDE
You can develop a C++ program from a command window or from an ____.
motherboard
a circuit case that connects the parts of a computer together.
block comment; paragraph comment
a comment enclosed between /* and */ on one or several lines.
line comment
a comment that is preceded by two slashes (//) on a line.
hardware and software
a computer includes
bus
a computer's components are interconnected by a subsystem called a
function
a construct that contains statements. -enclosed in a block start with a left brace { and ending in a right brace }
flash drive
a device for storing transporting data. -portable hard drive that can be plugged into your computer's USB port. -size of a pack of gum. -up to 256 GB of storage capacity.
network interface card (NIC)
a device that connects a computer to a local area network (LAN). -commonly used in universities, businesses, and government agencies - high-speed one known as 1000BaseT can transfer data at 1,000 million bits per second (mbps)
namespace
a mechanism to avoid naming conflicts in a large program.
preprocessor
a program that processes a source file before it is passed down to the compiler. -processes the directions.
source program; source code
a program written in a high-level language.
machine language
a set of built-in primitive instructions. -a computer's native language. -written in form of binary code. ex.) 1101101010011010
encoding scheme
a set of rules that governs how a computer translates characters, numbers, and symbols into data the computer can actually work with.
700 MB
a single CD can hold up to
multicore CPU
a single component with two or more independent cores.
prompt
a string that directs the user to input something.
gigabyte (GB)
about 1 billion bytes
megabyte (MB)
about 1 million bytes
terabyte (TB)
about 1 trillion bytes
kilobyte (KB)
about 1,000 bytes
Computer programs
aka software. Instructions that tell a computer what to do.
Universal serial bus (USB)
allow the user to attach various peripheral devices to the computer. -can use it to connect a printer, digital camera, mouse, external hard disk drive, and other devices to the computer.
Multithreading
allows a single program to execute multiple tasks at the same time. -a word-processing program allows users to simultaneously edit text and save it to a disk.
multiprogramming
allows multiple programs to run simultaneously by sharing the CPU. -uses the CPU when it would otherwise be idle. -ex.) allows you to use a word processor to edit a file at the same time as your Web browser is downloading a file.
dot pitch
amount of space between pixels, measure in millimeters.
assignment expression
an assignment statement is also known as an _______________ _____________.
computer
an electric device that stores and processes data. -consists of a CPU, memory, hard disk, monitor, printer, and communication.
named constant
an identifier that represents a permanent value. const datatype CONSTANTNAME = value;
C++
an object-oriented language, based on C.
CD-RW
can be used like a hard disk; you can write data onto the disc and overwrite the data with new data.
runtime errors
cause a program to terminate abnormally. -occur if the environment detects an operation that is impossible to carry out.
hardware
comprises the visible, physical elements of a computer
human
computer do not understand _____ languages, so you need to used computer languages to communicate with them.
memory
consists of an ordered sequence of bytes for storing programs as well as data that the program is working with. -computer's work area for executing a program.
C++ program-development process
consists of creating/modifying source code, compiling, linking, and executing programs.
cin
console input -causes a program to wait until data is entered at the keyboard and the Enter key is pressed.
C++ library
contains predefined code for developing C++ programs.
software
contains the instructions that tell a computer- or a computerized device- what to do.
C++ compiler
contains three separate programs: preprocessor, compiler, and linker.
console output
cout stands for this.
assembly language
created as an alternative to machine languages.
programming style
deals with what programs look like.
algorithm
describes how a problem is solved by listing the actions that must be taken and the order of their execution.
assignment statement
designates a value for a variable. variable = expression;
Visual Basic
developed by Microsoft and it enables the programmers to rapidly develop graphical user interfaces.
keyboard
device for entering input.
bits (binary digits)
digits in the binary number system and are labeled as 0s and 1s. -data of various kinds, such as numbers, characters, and strings, are encoded as a series of these.
monitor
displays information (text and graphics). -screen resolution and dot pitch determine the quality of the display.
comment
documents what the program is and how it is constructed. -help programmers to communicate and understand the program. -ignored by the compiler
//
double slashes -precedes a comment line.
on or off
each switch has two states:
end line
end stands for -ends a line and flushes the output buffer to ensure that the output is displayed immediately.
assignment operator
equal sign (=)
statement terminator
every statement in C++ must end with a semicolon (;)
semicolon (;)
every statement in the function ends with a ______.
CD-R
for read-only permanent storage. -user cannot modify its contents once they are recorded.
C++
general-purpose, object-oriented programming language.
keywords; reserved words
have a specific meaning to the compiler and cannot be used in the program for other purposes. ex.) using, namespace, int, and return
1
if the switch is on, the value is
motherboard
in personal computers, the bus is built into the computer's _________.
statements
instructions in a high-level programming language. ex.) statement that computes the area of a circle with a radius of 5: area = 5 * 5 * 3.1415
C++
is a general-purpose language, which means you can use it to write code for any programming task.
data types
kind of the data stored in a variable. e.g. float, integer
linker
links the machine-code file with supporting library files to form an executable file. -On Windows, machine-code file is stored on disk with an .obj extension and executable files have .exe -On UNIX, the machine-code file has an .o extension and the executable files do not have file extensions.
function keys
located across the top of the keyboard and are prefaced with the letter F. -what they do depends on the software being used.
arrow keys
located between the main keypad and the numeric keypad. -used to move the mouse pointer up, down, left, and right on the screen in many programs.
numeric keypad
located on the right side of most keyboards, is a separate set of key styled like a calculator and used to enter numbers quickly.
tracing a program
method of reviewing how a program works and helps find errors.
byte
minimum storage unit in a computer
errors
missing a closing brace, missing a semicolon, missing quotation marks for strings, and misspelling names are common ______ made by new programmers.
keyboards; mice
most common input devices
monitors; printers
most common output devices
operating system (OS)
most important program that runs on a computer. -manages and controls a computer's activities.
cin
object that reads input from the keyboard
logic errors
occur when a program does not perform the way it was intended.
input error
occurs when the program is waiting for the user to enter a value, but the user enters a value that the program cannot handle. ex.) if a program expects to read a number , but instead the user enters a string which causes data-type errors to occur.
< >
opening and closing angle brackets -encloses a library name when used with #include.
( )
opening and closing parentheses -used with functions such as main().
" "
opening and closing quotation marks -wraps a string (i.e., sequence of characters).
simultaneously
operating systems ensure that different programs and users working ______ do not interfere with each other.
memory unit
ordered sequence of bytes, each holds 8 bits.
arithmetic/logic unit
performs numeric operations (addition, subtraction, multiplication, and division) and logical operations (comparisons).
C++ compiler command
performs three tasks in sequence: proposing, compiling, and linking.
storage medium
physically stores data and program instructions.
return 0;
placed at the end of every main function to exit the program.
high-level language
platform-independent, which means that you can write a program in this language and run it in different types of machines. -English-like and easy to learn and use.
mouse
pointing device -used to move a graphical pointer (usually in the shape of an arrow) known as a cursor around the screen or click on-screen objects (such as a button) to trigger them to perform an action.
#
pound sign -used in #include to denote a preprocessor directive.
assembler
program used to translate assembly-language programs into machine code since the computer cannot execute assembly language.
software; programs
programming is the creation of
interpreter; complier
programming tool that translates a source program into machine code for execution because a computer cannot execute a source program. -reads one statement from the source code, translates it to the machine code or virtual machine code, and then executes it immediately.
software
provides the invisible instructions that control the hardware and make it perform specific tasks.
tasks of an operating system
recognizing input from the keyboard, sending output to the monitor, organizing files and folders on storage devices, and controlling peripheral devices, such as disk drives and printers.
variable
represents a value stored in the computer's memory
syntax errors
result from errors in code construction, such as mistyping a keyword, omitting necessary punctuation, or using an opening brace without a corresponding closing brace. -easy to detect. -compiler tells you where they are and what caused them.
fundamental types; primitive data types
simple data types provided by C++ for representing integers, floating-point numbers, characters, and Boolean types.
programming languages
software developers create software with the help of powerful tools called
IDE
software that provides an integrated development environment (IDE) for rapidly developing C++ programs.
modifier key
special key (such as the Shift, Alt, or Ctrl key) that modifies the normal action of another key when the two are pressed simultaneously.
screen resolution
specifies the number of pixels in horizontal and vertical dimensions of the display device.
>>
stream extraction operator; follows cin
<<
stream insertion operator -outputs to the console.
application programs
such as a Web browser or a word processor. -cannot run unless an operating system is installed and running on the computer.
variable declaration
tells the compiler to allocate appropriate memory space for the variable based on its data type. datatype variableName;
documentation
the body of explanatory remarks and comments pertaining to a program.
central processing unit(CPU)
the computer's brain. -retrieves instructions from memory and executes them.
identifiers
the names that identify elements such as variables and functions in a program.
core
the part of the processor that performs the reading and executing of instructions.
scope of a variable
the part of the program where the variable can be referenced.
DVD-R (read-only); DVD-RW (rewritable)
two types of DVDs.
insert, delete, page up, and page down keys
used in word processing and other programs for inserting text and objects, deleting text and objects, and moving up and down through a document one screen at a time.
indentation
used to illustrate the structural relationships between a program's components or statements.
unique address
used to locate the byte for storing and retrieving the data. -every byte in the memory has a ______ __________.
Hard disks
used to store data and programs permanently. - 200 to 800 GB of data. can be encased or removable. - at least one in a computer.
dial-up modem; regular modem
uses a phone line and can transfer data at speeds up to 56,000 bps (bits per second).
digital subscriber line (DSL) connection
uses a standard phone line, but it can transfer data 20 times faster than a standard dial-up modem.
cable modem
uses the cable TV line maintained by the cable company and is generally faster than DSL.
Multiprocessing; parallel processing
uses two or more processors together to perform subtasks concurrently and then combine solutions of the subtasks to obtain a solution for the entire task. -ex.) a surgical operation where several doctors work together on one patient.