What is wrong with the following pseudocode?
Declare Count As Integer
Declare TheNumber As Integer
Set TheNumber = 12
For (Count = 10; Count>TheNumber; Count--)
Write TheNumber + Count
End For
A) The limit condition in a For loop cannot be a variable
B) The loop will never be entered since the initial value of Count is less than the test condition
C) The loop will never end since the test condition will never be met
D) A counter must start at 0 or 1
Answer: Option B
Explanation: TheNum=12 and Count=10. For entering the loop the condition is Count>TheNumber and 10>12 is false and the loop will never be entered.
Please give a like
What is wrong with the following pseudocode? Declare Count As Integer Declare TheNumber As Integer Set...
In the pseudocode below: Function Integer perfect(Integer n) Declare Integer count = 0 Declare Integer sum = 0 While count < n Set count = count + 1 Set sum = sum + count End While Return sum End Function Function Integer perfect_sum(Integer n) Declare Integer count = 0 Declare Integer sum = 0 While count < n Set count = count + 1 Set sum = sum + perfect(count) End While Return sum End Function Module main() Display perfect_sum(5)...
Please select the output: 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 Num1 as ref, Integer Mum2 as reference) declare x as integer set Num1 = 3 set Num2 = 4 set x= 5 write x end subprogram Please select one: 5/42, 5/34, 5/32, 5/24 What is the output of this...
Convert the following pseudocode into C++ language. Declare X, Y, Z As Integer For (X = 1; X < 4; X++) Write “Pass Number “ + X For (Y = 1; Y < 10; Y+3) Set Z = X + Y Write X + “ + “ + Y + “ = “+ Z End For(Y) End For(X)
1. True/False: An infinite loop occurs in a pre-test loop when a test condition can never be met. 2. True/False: An infinite loop occurs in a post-test loop when a test condition can never be met. 3. True/False: The following statement will generate a loop with four iterations: for(count = 4; count > 0; count--) 4. True/False: The problem with a do...while loop is that the test condition cannot be a compound condition. 5. True/False: The following test...
MULTIPLE ANSWERS: Consider the following pseudocode snippet: Declare String springClasses[5] = “csc115”, “mat295”, “phy200”, “eng200”, “the120” Declare Integer index = 0 Display “displaying all classes” For index = 0 To 5 Display springClasses[index] End For Where is the syntax error in the following pseudocode? (If you are not sure here is a hint: go back and read up on For loops carefully. When do they stop looping?) Infinite loop We initialize the array with the wrong datatype Array out of...
loops a.Create a For loop with a variable i that is type integer. It is equal to 0 . Evaluate if i is less than three, then increment i. Statement should be to trace b. Create a For Loop with a variable i equal to 3. If I is greater than 0, decrement i. The statement should be to trace i c. Declare a variable for i to be an integer with a value of 0. While it is less...
In a class named Program8, write codes as follows: Declare a global integer variable called length and initialize it with zero as a default value. (Difficulty: easy) Write a method called setLength which accepts an integer input num and counts how many digits this number has and sets the global variable length with the result. This method does not return anything, instead it assigns a new value into the global variable length. This method should also work with negative numbers....
// Group Names: // Date: // Program Description: // Import required packages //--> // Declare class (SwitchDoLab) //--> { // Declare the main method //--> { // Declare Constant integers SUM = 1, FACTORIAL = 2, QUIT = 3. //--> //--> //--> // Create an integer variable named choice to store user's option. //--> // Create a Scanner object // Create...
Declare and initialize 4 Constants for the
course category weights:
The weight of Homework will be 15%
The weight of Tests will be 35%
The weight of the Mid term will be 20%
The weight of the Fin al will be 30%
Remember to name your Constants according to Java
standards.
Declare a variable to store the input for the number of
homework scores and use a Scanner method to read the value from the
Console.
Declare two variables: one...
Assume the following declarations have been made in main(): int howmany; Scanner kb = new Scanner(System.in); Random r = new Random(); Write code to do the following: Use a while loop to prompt the user for how many numbers are to be entered. If the user does not enter a positive number (a number greater than 0), display a message saying the number must be positive and to try again. Store this value in the howmany variable. Declare an integer...