Algorithm
step by step solution to solve a problem or to accomplish specific task.
Flowchart
graphical representation of algorithm. There are symbols and illustration to use.
Pseudo code
tool to plan the algorithm and use short English statements.
Programs
- instruction given to a computer.
IPO Chart
use to organized the result of program analysis.
compiler
converts programming language program to machine language
Computer Programming
It means giving instruction or directions to accomplish specific task
Analyze the problem
- Problem outline and list of requirements.
Plan the algorithm
Design algorithm using pseudo-code, IPO and flowcharts.
Check the algorithm
Trace algorithm.
Code the algorithm into a program.
implement algorithms into code.
Maintenance
Evaluate and modify the program if necessary. IPO chart is also applicable.
Interpreter
converts programming languages to machine language line by line
Machine Language
Instructions written in 0s and 1s are called _______. ___________ language (each type of machine has its own language) represent the only way to communicate directly with the computer
dataType varaibleName = value;
Write Data Types Syntax
const dataType varaibleName = value;
Write Data type of const
Assembly language
it simplify the programmer’s job by allowing the programmer to use mnemonics in place of the 0s and 1s in the program
High level language
It represent the next major development in programming languages. These languages are a vast improvement over machine and assembly language because they allow the programmer to use instructions that more closely resemble the English language.
Process
indicates any type of internal operation inside the Processor or memory
input/output
used for any _____/______ operation. indicates that the computer is to obtain data or output results
Decision
used to ask a question that can be answered in a binary format (yes/no, true/false
Connector
Allows the flowchart to be drawn without intersecting lines or without a reverse flow
Pre-defined Process
Used to invoke a subroutine or an interrupt program
Terminal
indicates the starting or ending of the program, process, or interrupt program.
Flow lines
show direction of flow
identifiers
All C++ variables must be identified with descriptive unique names. These unique names are called
==
equal to
! =
not equal to
<=
less than or equal to
>=
greater than or equal to
Sequence
In a computer program, the _________ structure directs the computer to process program instructions, one after another, in the order listed in the programs.
Selection
indicates that a decision (based on some condition) needs to be made followed by an appropriate action derived from that decision.
Repetition
or loops, are used when a program needs to repeatedly process one or more instructions until some condition is met, at which time the loop ends. Many programming tasks are repetitive, having little variation from one item to the next
Control Structures
All computer programs, no matter how simple or how complex, are written using one or more of three basic structures: Sequence, Selection, and Repetition. These structures are called __________ or logic structures because they control the flow of a program’s logic.
while loop
The loop construct in C++ is used when the number of iterations is known beforehand is called _________
Pseudo Code
The short English statements that represent an algorithm are called ____________
braces
In a C++ program, the body of a function is enclosed in ______
Compiler
Most high-level languages use a(n) _________________________ to translate the instructions into a language that the computer can understand.
High Level Language
When writing a(n) _________________________ program, the programmer concentrates on the major tasks
needed to accomplish a goal.
Object Oriented Program
When writing a(n) _________________________ program, the programmer breaks up a problem into
interacting objects.
Sequence
a series of actions that is completed in a specific order. Action 1 is performed, then Action 2, then Action 3, etc,. until all of the actions in the sequence have been carried out.
Diamond symbol
denotes decision symbol to represent condition in the selection and repetition structures.
For LOOP (__________, _____, _____)
Initialization, condition , Update
Continue Statement
1. if the condition is true, the iteration is continued in the loop otherwise the loop will stop.
2. if inside the loop, the continue skips the statements and transfer to execute the next loop.
Break Statement
1. user is not sure about the input value of iteration
2. user wants to stop the program based on different condition.
3. use also in switch statements.
Exception Handling
is a way of handling errors that may occur while the program is running, like dividing any number by zero.
try, throw, and catch
Exception handling is built upon three keywords
Try
Block identifies a block of code for which particular exceptions will be activated. It's followed by one or more catch blocks.
Throw
− A program throws an exception when a problem shows up.
Catch
A program catches an exception with an exception handler at the place in a program where you want to handle the problem.
Selection Structure, Sequence Structure and Repetition
Three types of control structure
Control Structure
It answers either true or false, yes or no, 1 or 0. The computer choose to execute depending on the operation used.
Array
Collection of elements that are of the same type. Group of related variables that have the same name and data type.
False
((5!=3) && (6<5))
TRUE
((6 == 6) && (6>3))
True
((6 == 6) || (6 < 3))
False
((5 == 3) || (6<3))
When need to use exception handling:
1. No new allocating memory - sometimes the storage is full and cannot allocate memory.
2. Division by zero
3. Invalid function parameter - occur in function overloading.
Post Test Loops
Condition is evaluated or tested after
the instruction.
It processed at least once.
Pretest Loops
Condition is evaluated or tested
first before the instruction.
The instruction is executed if the
condition is TRUE.
The loop repeats after the
executing the instruction.
Identifiers
can be short names (like x and y) or more descriptive names (age, sum, totalVolume).
B. %
Which of the following is a character literal constant?
a. ‘56’
b. ‘%’
c. “a”
d. Both a and b
d. All of the Above
Which of the following is a string literal constant?
a. “$”
b. “Good Morning”
c. “”
d. All of the Above
int population = 10000;
Write a C++ statement that declares and initializes an int variable named population.
const double MAX_PAY = 25.55;
Write a C++ statement that declares the MAX_PAY named constant. The constant should have a double data type and contain the number 25.55