Intro to Computer Programming part 3

¡Supera tus tareas y exámenes ahora con Quizwiz!

What is the value of X in the following expression? Set X = Str(-685.23)

"-685.23"

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

25 20 15

A data flow diagram shows the data imported by and exported from each program module.

True

When a subprogram is called, the values of the __________ are assigned to corresponding __________.

arguments, parameters

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

b. all of the above can be nested in a For loop

Programming languages usually supply an assortment of __________ functions

built-in

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)

3 4 6 8

If MyNumber = 7.82, what is the value of Int(MyNumber/2)+ 0.5?

3.5

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)

4

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

A jacket that originally costs $100 is on sale today for $80

A subprogram must always return a value to the program or subprogram that calls it.

False

Given that Number = 3: Floor(Random() * Number) + 4 may be 7, 8, 9, 10, 11, 12, or 13

False

If Number = 2.3, is the following statement true or false: Number == Int(Number)

False

Is the following statement true or false? Ceiling(6.89) == 6

False

Parameters, as well as arguments, can be constants, variables, or general expressions.

False

The Round(X) function and the Int(X) function do exactly the same thing.

False

To solve the problem of how to code a repeated multiplication problem, recursion must be used.

False

True/False: A For loop may not be nested within a While loop.

False

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.

False

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 <NL> While Count <= A Print Star Set Count = Count + 1 End While

Harold ******

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

It sums all the integers from 1 through 49

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 __________.

Mycount <= 25

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 __________.

Mycount+=5

A function's name may be assigned a value in the code that defines it.

True

Changes to the value of value parameters do not affect the value of the corresponding variables in the calling module.

True

Code for built-in functions is supplied by the programming language in separate modules, often referred to as a library.

True

Given that Number = 3: 6or 3, 4, 5, may beFloor(Random() * 4) + Number

True

It is possible to have both a Select Case statement and an If-Then structure within a single loop.

True

True/False: Two non-overlapping loops can be nested within a third loop.

True

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

a. 0, 1, 2, 3

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

a. all of the above are true

A Call statement that passes values to a subprogram contains the subprogram's name and, in parentheses, a list of:

arguments

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

bunny BUNNY bunny BUNNY

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

c. Floor(Random() * 5) + 5

The function that returns the number of characters in a string is the __________ function.

len()

If a variable is declared both locally and globally, it is treated as if it were two different variables, and the __________ declaration takes precedence.

local

The items appearing in a subprogram header are known as __________.

parameters

Numbers that form an unpredictable sequence in which each number is equally likely to occur are called __________ __________.

random numbers

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)

sandwich = soda, side = chips, drink = burger

Given the following two program statements, identify the parameters. Call DressUp(sandals, turtleneck, jeans) Subprogram DressUp(shoes, shirt, pants)

shoes, shirt, pants

When a variable is passed by __________ to a submodule, that submodule receives only a copy of that variable.

value

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)

3 4 6 8

The expression Floor(Random()*6) produces the numbers _____ through _____

0, 5

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)

13 14 14 15

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

20 divided by 5 = 4

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)

5 3 4 9 5 6

What is the value of X in the following expression, given that Y = 429: Set X = Round(Y/8)

54


Conjuntos de estudio relacionados

Health Assessment Ears, Nose, Mouth and Throat Quiz #7

View Set

Lesson 5: Configuring Network Addressing and Internet Connections

View Set

World History: Quiz 2 Between the Wars

View Set

Social Studies Unit 3: Latin and South American Revolutions

View Set