Final Exam
In a(n) __________ numbering system, all numeric values are written as sequences of 0s and 1s
Binary
Each byte is divided into eight smaller storage locations known as _____
Bits
Hierarchy chart/structure chart
Boxes that represent Each Module, the boxes are connected to illistrutate the Relationship of each other
A __________ is enough memory to store a letter of the alphabet or a small Largest number 255 --- 1 byte
Byte
Concatenation
The process of appending one string to the end of another string
Short circuits
When using AND logical operator if value on left is false then it does not evaluate the value on right
Declare String keepGoing = "y" Constant Real COMMISION_RATE = 0.10
While keepGoing == "y"
The substring function typically accepts three arguments:
(1) a string that you want to extract a substring from, (2) the beginning position of the substring, and (3) the ending position of the substring.
Math Operator
+ - / *
Disadvantage of repeating structure:
- The duplicated code makes the program large - Writing long sequence of statements can be time consuming - If part of the duplicated code has to be corrected or changed, then the changed has to be done many times.
Top down design Mechanical aspect of module Breakdown algorithm into module using top down design Process of top down design (stepwise refinement)
- The overall task that the program is to perform is broken down into a series of subtask - Each subtask is examined and determined if can be further broken down into subtask (until there's no subtask can be identified - Once all subtasks have been identified they are written into code
32
1+2+4+8+16+32 32(1) + 16(0) + 8(0) + 4(0) + 2(0) + 1(0) 100000
toLower function
Accepts a string as an argument and returns a string that is a copy of the argument, but with all characters converted to lowercase. Any character that is already lowercase or is not an alphabetic letter is left unchanged
toReal function
Accepts an integer number as its argument and returns that number converted to a real number. Declare Integer i = 7 Declare Real r Set r = toReal(i)
Contains function
Accepts two strings as arguments. It returns True if the first string contains the second string; otherwise, the function returns False
A set of well defined logical steps that must be taken to perform a task
Algorithm
So far we only use sequence structure - set of statement that execute in order they appear
Although sequence structure is use heavily used in programming, it cannot handle every type of task. One that executes statement only under certain circumstances. This can be accomplish with decision structure/selection structure
A count-controlled loop iterates a specific number of times.
Although you can write the logic of a condition-controlled loop so it iterates a specific number of times, the For loop, which is specifically designed as a count-controlled loop.
Passing Arguments by Reference
Argument is passed into a special type of parameter known as reference variable. When a reference variable is used as a parameter in a module, it allows the module to modify the argument in the calling part of the program
The Do-While loop is as POSTtest loop. This means it performs iteration before testing its condition.
As a result, the Do-While loop always performs at least one iteration, even if its condition is false to begin with
A ___program translated a high level language program into separate machine language program
Compiler
The __________ translates an assembly language program to a machine language
Compiler
Output column
Describes the Data that is returned From the Function.
Program development life cycle
Design the program -> Write the code -> Correct syntax error -> Test the executable code -> Debug the code <-- to design
Negating the Do Until
Do-While Loop
Once instructions have been inputted to the computer and translated into machine language a program can be ___________________
Execute
A ____ is a diagram that graphically depicts the steps that take place in a program
Flowchart
Function body
Following the function header is the which is comprised of one or more statements that are executed when the function is called.
Most languages let you assign an integer value to a real variable without causing an error because? Doing so does not cause a loss of data.
Functions for converting integers to real numbers still exist in case you need to explicitly perform this type of conversion
A debugging process in which you imagine that you are a computer executing a program
Hand Tracing
C++, Pascal
High Level Language
You never have to use the If-Then-Else If statement because its logic can be coded with nested If-Then-Else statements.
However, along series of nested If-Then-Else statements has two particular disadvantage when you debugging the code. - Code can be complex - Too long to be displayed in computer and tend to wrap around when it's printed
The while loop is known as a PREtest loop which means it tests its condition before performing the iteration. Priming Read (Before enter the loop - Declare String keepGoing = "y")
If loop is start like this: While keepGoing == "y" The loop will only perform an iteration only if the expression keepGoing == "y" is true.
If x >= 20 AND x <= 40 Then Display "The value is acceptable range" RELATIONAL OPERATOR
If x < 20 OR x > 40 Then Display "The value is outside the acceptable range." RELATIONAL OPERATOR
Designing a Count-Controlled While Loop
In pseudocode, you can use the following general format to write a count-controlled While loop: ➀ Declare Integer counter = startingValue Initialize a counter variable to the starting value. ➁ While counter <= maxValue Compare the counter to the maximum value. statement statementt ➂ Set counter = counter + 1 (ADD1 to the counter variable during each iteration) if not infinite End While The ➀, ➁, and ➂ callouts show where the initialization, test, and increment actions are performed.
Boolean variables
It can hold one of two values; true or false. Boolean variables are commonly use flags, which indicate whether specific condition exist
The Do-Until loop also performs a task at least once
It is the best choice, however, when you want to perform a task until a condition is true.
When a function finishes?
It returns a value back to the part of the program that called it
Each execution in the body of the loop is known as
Iteration
Optional Parameter
List Appears inside a set of parentheses. If the function does not accept arguments, then an empty set of parentheses will appear.
A group of statements that exist within a program for the purpose of performing a specific task is a(n) _____
Module
A loop that is inside another loop is called a nested loop.
A nested loop is a loop that is inside another loop.
IDE (Integrated Development Environment)
Most IDEs combine the following programs into one software package: ● A text editor that has specialized features for writing statements in a high-level programming language ● A compiler or interpreter ● Useful tools for testing programs and locating errors
When you pass an argument to a module.
Most programming language required that the argument and the receiving parameter variable be off the same data type. (Integer num1, Integer num2)
Library functions or Black Box Built in Function
Most programming languages come with a library of functions that have already been written are built into the programming language
Global Constant Global Variable
Named constant that is available to every module in a program Variable that is visible in every module
Two Complement
Negative numbers are encoded using this technique
A control structure is
a logical design that Controls the Order in which a set of statement executes
A decision structure allows
a program to perform actions only Under Certain Conditions
Sentinel
a special value that marks the end of a list of values.
toUpper function
all characters converted to uppercase.
A repetition structure
causes statement to execute repeatedly
The toUpper and toLower functions are useful
for Making case-insensitive string comparisons
The While loop is
ideal in situations where the condition might be false to start with, and in such cases you do not want the loop to iterate at all.
Passing argument by value
means that only a copy of the argument's value is passed into the parameter variable. If the content of the parameter variable are changed inside the module, it has no effect on the argument in the calling part of the program.
Programmers commonly use the term SCOPE to describe A variable is visible only to statements inside the variable's scope.
the part of the program in which a variable may be accessed.
The Do-While loop is also a
where a task must be Repeated As Long as a condition is True
Count controlled loops
Repeats a specific number of times
Main memory = Random Access Memory = Volatile Storage temporary Storage
Secondary Storage can hold data for long periods of time even when there is no power
The first line of the structure starts with the word Select, followed by testExpression (could be variable or value such as math expression)
Select month Case 1: Display "January" Case 2: Display "February" Case 3: Display "March" Default: Display "Error: Invalid Month" End Select
Using the counter variable, the loop typically performs the following three actions: initialization, test, and increment:
1. Initialization: Before the loop begins, the counter variable is initialized to a starting value. The starting value that is used will depend on the situation. 2. Test: The loop tests the counter variable by comparing it to a maximum value. If the counter variable is less than or equal to the maximum value, the loop iterates. If the counter is greater than the maximum value, the program exits the loop. 3. Increment: To increment a variable means to increase its value. During each iteration, the loop increments the counter variable by adding 1 to it.
In most programming language, the order of operation can be summarized as follow
1. Perform any operation that are enclosed in parentheses 2. Perform any operations that use exponent factor to raise a number to the power 3. Perform multiplication, division, or modulus operations as they appear from left to right 4. Perform any addition or substraction as they appear from let to right-
Reference variables are useful for establishing two way communication between modules. In these following ways:
1. The calling module can communicate with the called module by passing an argument 2. The called module can communicate with the calling module by modifying a value of the argument via the reference variable
Dual Alternative Decision Structure will execute one group of statements if its Boolean expression is true, or another group if its Boolean expression is false
A dual alternative decision structure has two possible paths of execution - One path is taken if condition is true, and Other path is taken if the condition false
An argument is any piece of data that is passed into a module when the module is called. Parameter/Parameter variables are a special variable that receives an argument when a module is called.
A parameter is a variable that receives an argument that is passed into a module. If you want a module to receive arguments when it is called, you must equip the module with one or more parameter variables.
Variable scope is part of the program in which the variable may be accessed.
A parameter variable scope is usually the entire module in which the parameter variable is declared.
Typically the boolean expression that is tested by an If Then statement is formed with a Relational Operator.
A relational operator determines whether a specific relationship Increase between Two Value
Program
A set of instructions that a computer follows to perform a task.
Function
A special kind of module that returns a value back to the part of the program that called it
Variable Uninitiated Variable
A storage location in memory that is represented by name The value is unknown and should be considered garbage
Sequence Structure
A(n) _____ is a set of statements that execute in the order that they appear.
A set of 128 numeric codes (UNICODE) that represent the English letters, various punctuation marks, and other characters is
ASCII (Use for string comparison)
The append function
Accepts 2 strings as arguments which we will refer to as string1 and string2. It returns a third string that is created by appending string2 to the end of string1. After the function executes, string1 and string2 will remain unchanged.
toInteger
Accepts a real number as its argument and returns that number converted to an integer. Declare Integer i Declare Real r = 2.5 Set i = toInteger(r)
The Do-Until Loop. Sometimes, however, it is more convenient to write a loop that iterates until a condition is true—that is, a loop that iterates as long as a condition is false, and then stops when the condition becomes true.
Notice that the Do-Until loop is a POSTtest loop. First, one or more statements are executed, and then a condition is tested. If the condition is false, the program's execution flows back to the point just above the first statement in the body of the loop, and this process repeats. If the condition is true, the program exits the loop.
Return statement
One of the statements in the function body must be A Return statement specifies the value that is returned from the function when the function ends.
The values on the right and left of the (+) operator are called 2, 4
Operand
Interpreter
Program that both translate and execute the instruction into high level language program
An informal language that has no syntax rules, and is not meant to be compiled or executed is called __________
Pseudocode
Floating Point
Real Numbers are encoded using this technique
Input column
Shows a Description of the Data that is Passed into the Function as Arguments
Process column
Shows a description of the Process that the function performs
An IPO chart
Simple but effective tool that programmers sometimes use while designing functions. IPO stands for input, processing, and output. It provides only brief descriptions of a function's input
A program benefits in the following ways when it is modularized:
Simpler code - a program is usually simpler and easier to understand Code reuse - module also reduce the duplication of code within a program --- write once and reuse it Better testing - when each task within a program is contained in its own module, testing become simpler Faster development - suppose programmer each program is perform to ask user name each time thus you only to write once one twice. Modules can be written for the commonly task (enter username), and those modules can be incorporated into each program that needs them Easier facilitation of teamwork
AND
The AND operator connects two Boolean expressions into one compound expression. Both suppressions must be true for the compound expression to be true
Both the While and Do-While loops cause a statement or a set of statement to repeat as long as a condition is true.
The Do-Until loop cause a statement or a set of statements to repeat until a condition is true.
NOT
The NOT operator is a unary operator, meaning it works with only one operand. The operand must be Boolean expression. The not operator the truth of its operand
OR
The OR operator connects two Boolean expressions into one compound expression. One or both subexpressions must be true for the compound expression to be true. It is only necessary for one of the subexpression to be true, and it does matter which
The case structure lets the value of a variable or an expression determine which path of the execution the program will take
The case structure is a multiple alternative decision structure it allows you to test the value of a variable expression and then use that value to determine which statement or set of statement to execute
Function header
The first line of a Function Definition that specifies the Data Type of the Value that is returned from the Function, the Name of the Function, and any Parameter Variables used by the function to accept arguments
Declare Integer hours, minutes, seconds For hours = 0 To 23 For minutes = 0 To 59 For seconds = 0 To 59 Display hours, ":", minutes, ":", seconds End For End For End For
The innermost loop will iterate 60 times for each iteration of the middle loop. The middle loop will iterate 60 times for each iteration of the outermost loop. When the outermost loop has iterated 24 times, the middle loop will have iterated 1,440 times and the innermost loop will have iterated 86,400 times!
Programing language provide a set of operators known as logical operators which can use to create complex Boolean expression
The logical AND operator and the logical OR operator allow you to connect multiple Boolean expression to create a compound expression. The logical NOT operator reverses the truth of a Boolean expression
The while loop gets its name from the way it works: While a condition is True, do some tasks.
The loop has two parts (1) A condition that is tested for a true or false value (2) a statement or set of statement that is repeated as long as the condition is true.
Return value
The value that follows the word Return is the value that the function will send back to the part. This can be any value, variable, or expression that has a
Running total is a sum of numbers that accumulates with each iteration of a loop.
The variable used to keep the running total is called an accumulator.
All programming languages allow you to create expression that can be evaluated as either True or False.
These are called Boolean expressions, named in honor english mathematician George Boole.
Instead of writing the same sequence statement over and over, a better way to repeatedly perform an operation is to write the code once and then placed that code in a structure that makes the computer repeat it as many times as necessary.
This can be done with a repetition structure which is more called as a LOOP
Nested Decision Structures
To test more than one condition, a decision structure can be nested inside another decision structure. Make it less complicated use case structure
Condition controlled loop
Uses True or False condition to control the number of times that it repeats
When you call a library function ?
Without requiring the function's code to appear in your program