Intro To Computer Programming Part 3

25 July 2022
4.7 (114 reviews)
47 test answers

Unlock all answers in this set

Unlock answers (43)
question
Which statement would produce an output of one of the following numbers: 5, 6, 7, 8, 9, 10 a. Floor(Random() * 9) - 5 b. Floor(Random() * 6) + 5 c. Floor(Random() * 5) + 5 d. Floor(Random()) + 5
answer
c. Floor(Random() * 5) + 5
question
What is the output of the code corresponding to the following pseudocode? Declare X As Integer Declare Y As Integer For (X = 1; X <=2; X++) For (Y = 3; Y <= 4; Y++) Write X * Y End For(Y) End For(X)
answer
3 4 6 8
question
Which of the following loops cannot be nested in a For loop? a. Do ... While b. all of the above can be nested in a For loop c. For d. While e. Repeat ... Until
answer
b. all of the above can be nested in a For loop
question
Given that Number = 3: 6or 3, 4, 5, may beFloor(Random() * 4) + Number
answer
True
question
True/False: A For loop may not be nested within a While loop.
answer
False
question
If a counter named MyCount in a For loop has the value of 5 on the first pass, 10 on the second pass, 15 on the third pass, and so on, the increment would be written as __________.
answer
Mycount+=5
question
What does the following program segment do? Declare Count As Integer Declare Sum As Integer Set Sum = 0 For (Count = 1; Count < 50; Count++) Set Sum = Sum + Count End For
answer
It sums all the integers from 1 through 49
question
Is the following statement true or false? Ceiling(6.89) == 6
answer
False
question
If Number = 4, what possible numbers can result from Floor(Random() * Number) a. 0, 1, 2, 3 b. 1, 2, 3, 4 c. 0, 1, 2, 3, 4 d. 4, 5, 6, 7, 8, 9, 10, 11, 12, 13
answer
a. 0, 1, 2, 3
question
What is the output of the code corresponding to the following pseudocode? Declare Y As Integer Declare X As Integer For (Y = 1; Y <=2; Y++) For (X = 3; X <= 4; X++) Write Y * X End For(X) End For(Y)
answer
3 4 6 8
question
If a counter named MyCount in a For loop has the initial value of 5 on the first pass and we want it to go through 4 iterations, increasing its value by 5 on each pass, the test condition would be written as __________.
answer
Mycount <= 25
question
What is the output of the code corresponding to the pseudocode shown? Declare G As Integer Declare H As Integer Set G = 7 While G <= 8 Set H = 6 While H <= 7 Write G + H Set H = H + 1 End While(H) Set G = G + 1 End While(G)
answer
13 14 14 15
question
If MyNumber = 7.82, what is the value of Int(MyNumber/2)+ 0.5?
answer
3.5
question
The function that returns the number of characters in a string is the __________ function.
answer
len()
question
If Number = 2.3, is the following statement true or false: Number == Int(Number)
answer
False
question
Code for built-in functions is supplied by the programming language in separate modules, often referred to as a library.
answer
True
question
Changes to the value of value parameters do not affect the value of the corresponding variables in the calling module.
answer
True
question
When a variable is passed by value, the submodule that variable is passed to will receive the actual storage location where the value of the variable is stored.
answer
False
question
What will be displayed after code corresponding to the following pseudocode is run? Main Set OldPrice = 100 Set SalePrice = 70 Call BigSale(OldPrice, SalePrice) Write "A jacket that originally costs $ " + OldPrice Write "is on sale today for $ " + SalePrice End Program Subprogram BigSale(Cost, Sale As Ref) Set Sale = Cost * .80 Set Cost = Cost + 20 End Subprogram
answer
A jacket that originally costs $100 is on sale today for $80
question
When a variable is passed by __________ to a submodule, that submodule receives only a copy of that variable.
answer
value
question
If a variable is declared both locally and globally, it is treated as if it were two different variables, and the __________ declaration takes precedence.
answer
local
question
A Call statement that passes values to a subprogram contains the subprogram's name and, in parentheses, a list of:
answer
arguments
question
A data flow diagram shows the data imported by and exported from each program module.
answer
True
question
What is the value of X in the following expression? Set X = Str(-685.23)
answer
"-685.23"
question
When a subprogram is called, the values of the __________ are assigned to corresponding __________.
answer
arguments, parameters
question
What is displayed after code corresponding to the following pseudocode is run? Set X = 15 Set Y = 25 Set Z = 20 Call Numbers(Y, Z, X) Subprogram Numbers(A, B, C) Write A + " " + B + " " + C End Subprogram
answer
25 20 15
question
Given the following function: Function DivideIt(X) As Float Set DivideIt = Int(X/2) End Function What is displayed when the following statement in the main program is executed? Write DivideIt(9)
answer
4
question
What is the value of X in the following expression, given that Y = 429: Set X = Round(Y/8)
answer
54
question
Programming languages usually supply an assortment of __________ functions
answer
built-in
question
Given the following statements, what values will be passed to the parameters (sandwich, side, and drink) of the subprogram named Lunch? Call Lunch(soda, chips, burger) Subprogram Lunch(sandwich, side, drink)
answer
sandwich = soda, side = chips, drink = burger
question
Given that Number = 3: Floor(Random() * Number) + 4 may be 7, 8, 9, 10, 11, 12, or 13
answer
False
question
Numbers that form an unpredictable sequence in which each number is equally likely to occur are called __________ __________.
answer
random numbers
question
True/False: Two non-overlapping loops can be nested within a third loop.
answer
True
question
What will be displayed after code corresponding to the following pseudocode is run? Declare A As Integer Declare B As Integer Declare C As Integer Set A = 3 While A <= 6 Set B = (2 * A) - 1 Write B Set C = A While C <= (A+1) Write C Set C = C + 1 End While(C) Set A = A + 2 End While(A)
answer
5 3 4 9 5 6
question
It is possible to have both a Select Case statement and an If-Then structure within a single loop.
answer
True
question
What is displayed when the following pseudocode is coded and run, given that the input is "Harold"? Declare Star As Character Declare A As Integer Declare Count As Integer Declare Name As String Set Star = "*" Write "Enter your first name: " Input Name Set A = Length_Of(Name) Set Count = 1 Print Name Print While Count <= A Print Star Set Count = Count + 1 End While
answer
Harold ******
question
The expression Floor(Random()*6) produces the numbers _____ through _____
answer
0, 5
question
What will be displayed after code corresponding to the following pseudocode is run? Declare Word As String Declare Count As Integer Set Word = "Bunny" Set Count = 1 While Count < 5 If Floor(Count/2) == Count/2 Then Set Word = ToUpper(Word) Else Set Word = ToLower(Word) End If Write Word Set Count = Count + 1 End While
answer
bunny BUNNY bunny BUNNY
question
The Round(X) function and the Int(X) function do exactly the same thing.
answer
False
question
A subprogram must always return a value to the program or subprogram that calls it.
answer
False
question
A function's name may be assigned a value in the code that defines it.
answer
True
question
Given the following two program statements, identify the parameters. Call DressUp(sandals, turtleneck, jeans) Subprogram DressUp(shoes, shirt, pants)
answer
shoes, shirt, pants
question
What will be displayed after code corresponding to the following pseudocode is run? Main Declare A As Float Declare B As Float Set A = 4 Set B = 20 Call Math(A, B) Write B + " divided by " + A + " = " + B/A End Program Subprogram Math(Float Num1 As Ref, Float Num2) Set Num1 = 5 Set Num2 = 25 End Subprogram
answer
20 divided by 5 = 4
question
To solve the problem of how to code a repeated multiplication problem, recursion must be used.
answer
False
question
Parameters, as well as arguments, can be constants, variables, or general expressions.
answer
False
question
Using arguments and corresponding parameters to pass data among program modules is an important feature of modular programming because: a. all of the above are true b. it makes it easier for different programmers to design and code different subprograms c. it makes it easier to test and debug a subprogram independently of the main program d. it enhances the usefulness of subprograms
answer
a. all of the above are true
question
The items appearing in a subprogram header are known as __________.
answer
parameters