CSC 120 Final Exam
What is a variable?
A data item that CAN change during a process
What is an algorithm?
A sequence of steps to get to a solution
What type of chart is an overview of the program and shows the interconnections of the program modules?
A structure chart
What is an accumulator?
A value that adds to a variable but the value can vary
What chart technique describes a program using English-like words?
Pseudocode
What are the three sequential statements?
Read, Calculate, Print
What are three sequential statements?
Read, Calculate, Print
What are the three types of generic process data modules
Read, Calculate, and Print
What specific structure is best suited for processing an undetermined number of loop items and at least zero items may be processed?
Pre-Test Loop
What is the least number of times a pre-test loop could loop?
0 times
What is the least number of times an automatic loop counter loop could loop?
0 times
What is the least number of decision statements that could be processed with 6 items using a positive logic structure?
1
List two generic string functions presented in the text, give a brief description of each.
1) Length: The number of characters in the function 2) Mid: The middle characters of the function
List the steps to your problem solving Heuristic:
1. Identify the problem 2. Understand the problem 3. List possible solutions 4. Determine the best possible solution 5. List instructions 6. Evaluate the solution
Evaluate A+B/(C-D^2) when A = 12, B = 3, C = 6, and D = 2
13.5
How many decision statements are needed to process 6 items with a positive logic structure?
5
What is the result of (A+B)\C^2, when A=15, B=6, C=2
5
What symbol terminates a completed C statement?
; , semicolon
What is the least number of times a post-test loop could loop?
Once
List and describe the two integer mathematical operators.
Integer Division: Gives Remainder Modulus: Gives Number of times n can go into the number being squared
Which loop is best suited when you know how many items you need to process?
Automatic counter loop
What is a pass by value parameter?
It's a copy
What logical operator has the highest order of operation?
NOT
What symbols are used to block, group, C statements together as one?
Braces
What are the symbols that enclose a parameter list in C?
Parenthesis
What construct is best suited to process menu selections?
Case Statements (Ex: user chooses 1, 2, or 3 and your program needs to act based on their choice)
What is a variable called when a user changes it and it changes the program flow?
Code
Identify the four generic modules, exclude object oriented, and include any sub parts where appropriate
Control Module, Process Modules: (Read/Validate, Calculate, Print), Initialize Module, Wrap-Up Module
What term describes the functional dependence of two modules?
Coupling
List the operators in their order of Hierarchy
Parenthesis, Functions, Exponents, Modulus & Integer Division, Multiplication & Division, Addition & Subtraction, Relational Operators, Not, And, Or
What symbol identifies a pre-processor directive in C?
Pound symbol
Setup a logical expression for the following conditions: A retail store has this check-cashing policy: the costumer must have a driver's license; when the check is for more than $50.00, the customer must have a check-cashing card on file.
DL (C<=50 or CCC)
What Logical operator has the highest order of precedence?
Not
What is the result of Z<5 OR X*Y <=Z AND Z/Y+2<Y, when X=3, Y=7, Z=12
False
What type of chart is a graphical representation of the "algorithm"?
Flowchart
What are the five charting techniques listed in the text?
IPO, Problem Analysis, Psuedo code, Flow Chart, Modular Chart
Write the Pseudo code for a nested decision statement which will use two variables: age and cost. Age is already set by the user simply use it in your decision statements. Set Cost to 100 when age is between 16 and 65 (not inclusive), set cost to 50 when age is 65 or more, and set cost to 75 otherwise. Use any of the three logic structure to nest the decision statements.
If (Age>=65), then Cost= 50 Else If (Age>16), then Cost= 100 Else Cost= 75 End If End If Print "Cost", cost
Write pseudo-code for a structure to set grade equal to: 'A' if average is 90 and above 'B' if average is 80 up to 90 'C' if average is below 80
If (avg >= 90) then grade = 'A' else If (avg >= 80) then grade = 'B' else grade = 'C' end if end if
What is the simplest form of a decision statement?
If (condition), then Body End if
When is the action performed in a positive logic structure?
In the true body
What pre-processor directive in C identifies where to look for a function that is used but not defined in the program?
Include
What is a variable called when a programmer changes it and it changes the program flow?
Indicator
How many times will the following loop execute? while(4=4) print "hello" end loop
Infinitely
What needs to be done before you enter a pre-test loop?
Initialization
What are the four types of generic modules used for the solutions to most problem?
Initialize, process, control, wrap up
Declare a C integer named X, use any valid C integer type you like?
Int x;
List the five generic data types:
Numeric: Integer, Real Numbers, Character, String, and Logical
What is a variable
Something that can change during the process
What is the C header file that contains the basic input/output functions?
Stdio.h
What are the three logic structures for nesting decision statements?
Straight Through Logic, Positive Logic, and Negative Logic
When a global and a local variable have the same name which one is used by a module?
The most local
When a local and global variable have the same name, which is used by a module?
The most local
What type of chart separates a problem into four categories: the given data, the required results, the processing required, and the solution alternatives?
The problem analysis chart
What is the result of A AND B AND B OR C, when A=TRUE, B=TRUE, C=FALSE
True
What needs to be done before you end a pre-test loop?
Update the condition
What are the four pointers to follow that help you develop efficient computer solutions to problems?
Use modules, use the three logic structures, eliminate redundancy by using modules, use techniques to improve readability
What is an expression?
Uses relative operands to create a problem
When is an OR operation false?
When all operands are false
Using C syntax, initialize the variable X to 7?
X = 7;
Write the output of the following program module? X=0 Y=0 REPEAT Y=Y+X X=X+1 UNTIL Y>8 PRINT(Y)
Y: 10 Y X 0 0 0 1 1 2 3 3 6 4 10
What function is processed when the program is ran?
int main
Write the output for the following segment of code:
loop i = 1 to 5 step i i j loop j = 2*i to 40 step i+j 1 2 print i, j 1 5 end loop j 1 11 end loop i 1 23 2 4 2 10 2 22 4 8 4 20
What is the case C statements are written in?
lower case
How many decision statements will be processed for n items when a straight through logic structure is used?
n
