All Matches
Solution Library
Expert Answer
Textbooks
Search Textbook questions, tutors and Books
Oops, something went wrong!
Change your search query and then try again
Toggle navigation
FREE Trial
S
Books
FREE
Tutors
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Ask a Question
Search
Search
Sign In
Register
study help
computer science
prelude to programming
Questions and Answers of
Prelude to Programming
Changes to a reference parameter in a subprogram affect the corresponding argument in the calling module.True of False
The ToUpper() and ToLower() functions can take a variable of any data type.True of False
The statement: Display ToUpper("Yes") is not allowed because "Y" is already uppercase.True of False
What data is passed from the main program to the subprogram? Main Declare X As Integer Set X = 1 Call Display (2*X,X,5) End Program Subprogram Display(Integer Numl, Integer Num2, Integer Num3) Write
What data is imported by the subprogram Display? Main Declare X As Integer Set X = 1 Call Display(2*X,X,5) End Program Subprogram Display(Integer Numl, Integer Num2, Integer Num3) Write Numl + + Num2
Draw a data flow diagram for this program. Main Declare X As Integer Set X = 1 Call Display(2*X,X,5) End Program Subprogram Display(Integer Numl, Integer Num2, Integer Num3) Write Numl + + Num2 + +
If code corresponding to this pseudocode is run but X is initially set to 4, what is the output of this program? Main Declare X As Integer Set X = 1 Call Display(2*X,X,5) End Program Subprogram
If code corresponding to this pseudocode is run, as given, with X = 1, what is the output of this program? Main Declare X As Integer Set X = 1 Call Display(2*X,X,5) End Program Subprogram
Suppose that in the subprogram, all occurrences of Num1, Num2, and Num3 were replaced by A, B, and C, respectively. If code corresponding to the resulting pseudocode were run as in Exercise 19, what
Write a subprogram called Input_Data() that inputs two numbers from the user and exports their values to the main program.
Write a subprogram called Flip() that imports two variables from the main program (into parameters X and Y), interchanges their values, and exports the results to the main program.
What is the scope of the following variables?a. X, declared in the main program?b. X, declared in the subprogram? Main Declare X As Integer, Y As Integer Set X = 1 Set Y = 2 Call Sub(X, Y) Write X
List the local and global variables in this program. Main Declare X As Integer, Y As Integer Set X = 1 Set Y = 2 Call Sub(X, Y) Write X Write Y End Program Subprogram Sub(Integer Numl, Integer Num2
List the value and reference parameters in the subprogram Sub. Main Declare X As Integer, Y As Integer Set X = 1 Set Y = 2 Call Sub(X, Y) Write X Write Y End Program Subprogram Sub(Integer Numl,
What is the output of this program if code corresponding to this pseudocode is run? Main Declare X As Integer, Y As Integer Set X = 1 Set Y = 2 Call Sub(X, Y) Write X Write Y End Program Subprogram
Suppose the subprogram header is changed to the following:Subprogram Sub(Integer Num1 As Ref,Integer Num2)If code corresponding to the new pseudocode is run, what is the output now? Main Declare X As
Suppose the subprogram header is changed to the following:Subprogram Sub(Integer Num1,Integer Num2)If code corresponding to the new pseudocode is run, what is the output now? Main Declare X As
a. Abs(0)b. Abs(−1.5)Give the value returned by the built-in function.
a. Round(3.8)b. Round(Abs(−1.4))Give the value returned by the built-in function.
a. Str(10.5)b. Val("ten",N)Give the value returned by the built-in function.
a. Str(Val("−1.5",N))b. Val(Str(87.6),N)Give the value returned by the built-in function.
a. ToUpper("N")b. ToUpper("Nancy Newley")Give the value returned by the built-in function.
a. ToLower("N")b. Length_Of(ToLower(Name)), where Name is a String variable and Name = "Nancy Newley"Give the value returned by the built-in function.
Given the Float variables: Charge = −87.23 and Cost = 456.87a. Val(Str(Cost),N)b. Abs(Round(Charge))Give the value returned by the built-in function.
Refer to Example 9.15. Add the following functionality to this program: Allow the user to enter the cost of a gallon of gas on each trip and use a function, Cost() to calculate the cost of purchasing
Suppose a program contains the following function:Function F(X) As Float Set F = X + 1End FunctionWhat is displayed when the statementWrite F(3) in the main program is executed?
Given the function of Exercise 37, what is displayed when the statement:Write F(F(0))in the main program is executed?Data from Exercise 37Suppose a program contains the following function:Function
Given the functions of Exercises 37 and 39, what is displayed when the statementWrite G(1,F(1)) in the main program is executed?Data from Exercise 37Suppose a program contains the following
Write a functionFunction Average(Num1,Num2) As Float that finds the mean, (Num1 + Num2)/2, of the numbers Num1 and Num2.
Write a Main module (main program) that inputs two numbers from the user, calls the Average() function of Exercise 41 to find the mean of these numbers, and displays the result.Data from Exercise
What is the output of this program if K = 1? Main Declare K As Integer Input K Set Result = F(K) Write Result End Program Function F(N) As Integer If N == 1 Then Set F = 1 Else Set F = N * F(N-1) Set
If K = 3, how many times is the function F() called? Main Declare K As Integer Input K Set Result = F(K) Write Result End Program Function F(N) As Integer If N == 1 Then Set F = 1 Else Set F = N *
What is the output of this program if K = 3? Main Declare K As Integer Input K Set Result = F(K) Write Result End Program Function F(N) As Integer If N == 1 Then Set F = 1 Else Set F = N * F(N-1) Set
Write a nonrecursive function (using a loop) that has the same effect as F(). Main Declare K As Integer Input K Set Result = F(K) Write Result End Program Function F(N) As Integer If N == 1 Then Set
Write a recursive function Mult(M,N) that multiplies the positive integers M and N by using the fact thatM × N = M + M + . . . + M (N times).
Write a nonrecursive function (using a loop) that has the same effect as the recursive function Mult(M,N) of Exercise 47.Data from Exercise 47Write a recursive function Mult(M,N) that multiplies the
In a serial search, the item you are looking for is called the __________.
Input a list of employee names and salaries, sort them ascending by salary, and determine the mean (average) salary as well as the number of salaries above, below, and, if any, exactly at the mean.
In performing a bubble sort to arrange the numbers 5, 30, 25, 15 in ascending order, ____________ interchanges will take place.
Determine the median selling price of all homes in a subdivision named Botany Bay sold during one year. Allow the user to enter the number of houses sold and store their selling prices in an array.
When performing a search of two parallel arrays, when the item is found in one array, its __________ value identifies the corresponding element in the other array.
One problem with the selection sort routine is that it can only be used on arrays with numeric data types.True of False
Given the following array, write a program to sort the array using a selection sort and display the number of scores that are less than 500 and those greater than 500. Scores [0] 198 Scores [1] = 486
In a binary sFalseearch, the values of Low (identified initially, the first element in the array) and High (identified initially, the last element in the array) will never change as the program
At the end of the first pass through the outer loop of an array that is to be sorted in ascending order, using the selection sort method the __________ element will be the first element.
Assume the following array is parallel to the Scores array of Programming Challenge 3. Write a program to sort this Player array in alphabetical order, keeping the Scores array parallel. Use either
In a binary search of an array named MyArray, the first time the program runs, the value of Low will be ____________.
Redo Programming Challenge 4 but sort by Scores. Sort the Scores in ascending order, keeping the Player array parallel. To get your column data to line up as shown, you can use the tab indicator, /t,
Items must be sorted in descending order to perform a serial search.True or False
Write a program to load an array, Squares, with 100 numbers. Each element should contain the square of its index value. In other words, Squares[0] = 0, Squares[3] = 9, Squares[8] = 64, and so on.
On the first pass through a loop using a binary search, each element in the array is checked.True of False
Redo Programming Challenge 6 but use a binary search.Bonus: Add pseudocode to check how many iterations must be made for each number entered by the user, and, if you also complete Programming
In a serial search, the search key (the value being searched for) is compared with each element in an array until a match is found or there are no more elements in the array.True of False
Both search algorithms presented in this chapter can be used with parallel arrays.True of False
Before using the serial search method, you must sort the table keys in ascending order.True of False
The bubble sort method cannot be used to arrange numeric data in descending order.True of False
The binary search procedure can only be used with numeric data.True of False
A binary search requires that the data be sorted before beginning the search.True of False
How many interchanges take place when sorting the following numbers in descending order, using the bubble sort technique?6 9 5 8
Write a program segment to sort the given array in alphabetical order using the bubble sort method. Pet[0] "dog" Pet [1] "cat" Pet [2] = "bird" %3D Pet[3] "snake" Pet [4] "duck" Pet [5] "fish" %3D
What is the maximum number of passes that would be made to ensure that an array with 50 elements is sorted, using the bubble sort technique?
Write a program to perform a serial search on the given array for the key "duck". Pet[0] "dog" Pet [1] "cat" Pet [2] = "bird" %3D Pet[3] "snake" Pet [4] "duck" Pet [5] "fish" %3D %3D Pet[6] "rabbit"
Write a program segment to sort the given array in alphabetical order using the selection sort method. Pet[0] "dog" Pet [1] "cat" Pet [2] = "bird" %3D Pet[3] "snake" Pet [4] "duck" Pet [5] "fish" %3D
The following program segment is supposed to search an array A consisting of N elements for a value Key and set Found equal to 1 or 0, depending on whether Key is located. It contains two errors.
In Exercise 22, which variable is the flag for this program segment?Data from Exercise 22 Set Index = 0 %3! Set Found = 0 While (Found If A[Index] == Key Then 1) AND (Index < N) Set Found = 0 %3D Set
Assuming you have sorted the given array, write a program to perform a binary search for the element "pony". Pet[0] "dog" Pet [1] "cat" Pet [2] = "bird" %3D Pet[3] "snake" Pet [4] "duck" Pet [5]
What are the values of A[K] and A[K+1] after code corresponding to the following pseudocode is run?Set A[K] = 10Set A[K+1] = 20Set Temp = A[K]Set A[K] = A[K + 1]Set A[K + 1] = TempWrite A[K]Write A[K
What are the values of A[K] and A[K+1] after code corresponding to the following pseudocode is run?Set A[K] = 10Set A[K + 1] = 20Set A[K] = A[K + 1]Set A[K + 1] = A[K]Write A[K]Write A[K + 1]
The following program segment is supposed to sort an array A consisting of N numbers in ascending order. It contains two errors. Correct them. Assume that the array A and the other variables have
On entering the While loop for the first time, what is the value of Index?The following pseudocode used to perform a binary search of the names "Arnold", "Draper", "Gomez", "Johnson", "Smith", "Wong"
After the first pass through the While loop, what are the values of Low and High?The following pseudocode used to perform a binary search of the names "Arnold", "Draper", "Gomez", "Johnson", "Smith",
How many passes are made through the While loop?The following pseudocode used to perform a binary search of the names "Arnold", "Draper", "Gomez", "Johnson", "Smith", "Wong" (stored in Array), for
After the While loop is exited, what is the value of Found?The following pseudocode used to perform a binary search of the names "Arnold", "Draper", "Gomez", "Johnson", "Smith", "Wong" (stored in
How many passes are made through the outer For loop?The following pseudocode, which is used to perform a selection sort in ascending order on the names "Wong", "Smith", "Johnson", "Gomez", "Draper",
After the first pass through the first inner For loop, what is the value of Index?The following pseudocode, which is used to perform a selection sort in ascending order on the names "Wong", "Smith",
After the first pass through the outer For loop, which name is stored in Array[1]?The following pseudocode, which is used to perform a selection sort in ascending order on the names "Wong", "Smith",
What changes must be made to this pseudocode to sort this array of six names in descending order?The following pseudocode, which is used to perform a selection sort in ascending order on the names
Input a list of positive numbers (terminated by 0) into an array, find the largest number in the array, and output the result. Use a subprogram to input the numbers, a function to find the largest
If a data item is transmitted from a subprogram to the main program, it is said to be returned to or ____________ to the main program.
Input a list of positive numbers (terminated by 0) into an array, find the mean (average) of the numbers in the array, and output the result. Use a subprogram to input the numbers, a function to find
If a data item is transmitted from the main program to a subprogram, it is said to be passed to or ____________ by the subprogram.
Develop a menu-driven program that inputs a number X, and at the user’s choice, finds and displays the area (A) of one of the following:● A square with side X (use A = X^2)● A circle with
A diagram that shows the data transmitted between program modules is called a(n) ____________.
The factorial of a positive integer N, denoted by N!, is defined by the following:N! = 1 × 2 × . . . × N (Note: 0! = 1 )Using subprograms and functions, create a recursive program to compute N!.
A chart that shows the data that is imported to, processed by, and exported from each program module is called a(n) ____________.
Create a program that will input a positive integer from the user. The program should check to make sure the entry is a positive integer and then check to see if the number is a prime number. A prime
Add statements to the following pseudocode to create a post-test loop which validates the input data:Declare Number As IntegerWrite "Enter a negative number: "Input Number
Write a program that allows the user to enter his or her name. The program should output a username for entry into a website. The user should be prompted to enter a first name, middle initial, and
Suppose that X = "A". What is displayed when code corresponding to the following program segment is run? If X "B" Then Write "Hi" End If Write "Bye"
What is the output of code corresponding to the following pseudocode? Declare Q[10,10] As Integer Declare R, C, As Integer 1; R
Write a program segment that sums the elements in each row of the array X of Exercise 32 and displays these five numbers.
Write a program segment that declares a two-dimensional array X of integers with five rows and five columns and inputs 25 integers into this array from the user.
Assume you are writing a program for a man who sells picture frames that he makes in his garage. List at least three types of information that he might require to be stored in parallel arrays if he
Write a program segment that displays the person’s last name.An array has been declared by the following:Declare FullName[25] As Characterand contains a person’s first and last names, separated
Write a program segment that displays the person’s initials, with a period after each initial.An array has been declared by the following:Declare FullName[25] As Characterand contains a person’s
Write a program segment that displays the number of letters in the person’s first name.An array has been declared by the following:Declare FullName[25] As Characterand contains a person’s first
Write a statement that displays the length of the string in the array FullName.An array has been declared by the following:Declare FullName[25] As Characterand contains a person’s first and last
Write a program segment that displays the characters in Name except the blank. Declare Name[20] As Character Declare K As Integer Set K = 0 %3D While K < 8 Set Name [K] = "A" %3D Set K = K + 1 End
Write a single statement that displays the first and last characters in Name. Declare Name[20] As Character Declare K As Integer Set K = 0 %3D While K < 8 Set Name [K] = "A" %3D Set K = K + 1 End
Explain why a variable that is used as a flag to indicate when a condition becomes true or false is normally a Boolean variable.
Showing 100 - 200
of 587
1
2
3
4
5
6