Question

What will the following pseudocode program display

What will the following pseudocode program display?
Module main( )
Declare Integer x = 1
Declare Real y = 3.4
Display x, " ", y
Call changeUs(x, y)
Display x, " ", y
End Module
Module changeUs(Integer a, Real b)
{
Set a = 0
Set b = 0
Display a, " ", b
}
0 0
Add a comment Improve this question Transcribed image text
Answer #1
To do this kind of exercise, it is best to make a table of values of each of the variables. Proceed to execute the program and make changes to the variables requested by the code.

I will make a start:
x y a b code
- - - - Module main( )
1 - - - Declare Integer x = 1
1 3.4 - - Declare Real y = 3.4
***************
**** 1 3.4 **** Display x, " ", y
***************
1 3.4 - - Call changeUs(x, y)
1 3.4 1 3.4 Module changeUs(Integer a, Real b)
1 3.4 0 3.4 Set a = 0
1 3.4 0 0 Set b = 0
*************
**** ? ? **** Display a, " ", b
*************
*************
**** ? ? **** Display x, " ", y
*************
End Module

Can you take it from here?
answered by: patrik
Add a comment
Answer #2
Assistance needed.

Please type your subject in the School Subject box. Any other words are likely to delay responses from a teacher who knows that subject well.
answered by: landon
Add a comment
Answer #3
. (TCO 4) What will the following pseudocode display?
Declare Integer x = 3
Declare Integer y = 8
If x < 10 Then
If y > 5 Then
Display "Al can join."
Else
Display "Mary can join."
End If
Else
If y > 5 Then
Display "Mike can join."
Else
Display "Suong can join."
End If
End If
answered by: troyer02
Add a comment
Answer #4
As Quidditch correctly mentioned, it is necessary to know if the module ChangeUs() passes the parameters by value, i.e. make a copy, or by reference, i.e. give the address of the variables, so that any change inside of ChangeUs will affect the value of the variable in the calling module.
answered by: paulie
Add a comment
Answer #5
For the pseudocode you need to know if variables passed to the module are passed by reference or passed by value.

It is likely that they are passed by value.

Look at all your display statements. Think what each will show. The "Display" function probably adds end of line stuff. Otherwise, all display would be on one line.

The first one is:
1 3.4
answered by: Nichelle
Add a comment
Answer #6
true
answered by: Niyah
Add a comment
Answer #7
1. (TCO 4) What will the following pseudocode display?
Declare Integer x = 3
Declare Integer y = 2
If x < 10 Then
If y > 5 Then
Display "Al can join."
Else
Display "Mary can join."
End If
Else
If y > 5 Then
Display "Mike can join."
Else
Display "Suong can join."
End If
End If
(Points: 1)
Al can join.
Mary can join.
Mike can join.
Suong can join.


2. (TCO 4) What will the following pseudocode display?
Declare Integer x = 3
Declare Integer y = 8
If x < 10 Then
If y > 5 Then
Display "Al can join."
Else
Display "Mary can join."
End If
Else
If y > 5 Then
Display "Mike can join."
Else
Display "Suong can join."
End If
End If
(Points: 1)
Al can join.
Mary can join.
Mike can join.
Suong can join.


3. (TCO 4) What will the following pseudocode display?
Declare Integer x = 12
Declare Integer y = 8
If x < 10 Then
If y > 5 Then
Display "Al can join."
Else
Display "Mary can join."
End If
Else
If y > 5 Then
Display "Mike can join."
Else
Display "Suong can join."
End If
End If
(Points: 1)
Al can join.
Mary can join.
Mike can join.
Suong can join.


4. (TCO 4) What will the following pseudocode display?
Declare Integer x = 13
Declare Integer y = 4
If x < 10 Then
If y > 5 Then
Display "Al can join."
Else
Display "Mary can join."
End If
Else
If y > 5 Then
Display "Mike can join."
Else
Display "Suong can join."
End If
End If
(Points: 1)
Al can join.
Mary can join.
Mike can join.
Suong can join.


5. (TCO 4) What value will be stored in the Boolean variable result in the following pseudocode?
Declare Integer x = 5
Declare Integer y = 10
Declare Boolean result
Set result = ( x != y OR y >= 6 )
(Points: 1)
True
False


6. (TCO 4) What value will be stored in the Boolean variable result in the following pseudocode?
Declare Integer x = 5
Declare Integer y = 10
Declare Boolean result
Set result = ( x < y OR y > 12 )
(Points: 1)
True
False


7. (TCO 4) What value will be stored in the Boolean variable result in the following pseudocode?
Declare Integer x = 5
Declare Integer y = 10
Declare Boolean result
Set result = ( x < y AND y < 6 )
(Points: 1)
True
False


8. (TCO 4) What value will be stored in the Boolean variable result in the following pseudocode?
Declare Integer x = 5
Declare Integer y = 10
Declare Boolean result
Set result = ( x > y XOR y < 12 )
(Points: 1)
True
False


9. (TCO 4) What value will be stored in the Boolean variable result in the following pseudocode?
Declare Boolean isExpensive = True
Declare Boolean isAvailable = False
Declare Boolean result
Set result = NOT (isExpensive AND isAvailable)
(Points: 1)
True
False


10. (TCO 4) What value will be stored in the Boolean variable result in the following pseudocode?
Declare Boolean isExpensive = True
Declare Boolean isAvailable = True
Declare Boolean result
Set result = ( isExpensive XOR isAvailable )
(Points: 1)
True
False
Add a comment
Know the answer?
Add Answer to:
What will the following pseudocode program display
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Given the following pseudocode: Class Coordinate Private Real _x Private Real y Public Module set_x(Real value)...

    Given the following pseudocode: Class Coordinate Private Real _x Private Real y Public Module set_x(Real value) Set _X = value End Module Public Module set_y(Real value) Set y = value End Module Public Function get_x() Return _X End Module Public Function get_y() Return y End Module Public Module add(Coordinate c) Set _X = _X + C.get_x) Set y = y + c.get_y() End Module End Class Module main() Declare Coordinate ci - New Coordinate() Declare Coordinate c2 - New Coordinate()...

  • In the pseudocode below: Function Integer perfect(Integer n) Declare Integer count = 0 Declare Integer sum...

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

  • I am supposed to a pseudocode function named max that accepts two integer values as arguments...

    I am supposed to a pseudocode function named max that accepts two integer values as arguments and returns the value that is greater of the two. Use the function in a program that prompts the user to enter two integer values. The program should display the value that is greater of the two. Is everything correct and complete? //Pseudocode //This function takes two integers as parameters: x and y Begin : Max(x,y) If(x>y) then MAX=x Else MAX=y End if Return...

  • 1. What are the problems with the following pseudocode? Be careful here, this one is tricky!...

    1. What are the problems with the following pseudocode? Be careful here, this one is tricky! Module main()   Number siblingAge = 12 Display “your “+siblingType+ “ has”     yearsUntilAdult(siblingAge) Display “years until they are an adult” End Module Module yearsUntilAdult(Number inAge) Character siblingType = “sister” If inAge < 18 Then Display inAge - 18 Else Display 0 End If End Module A. yearsUntilAdult module call can not see variable siblingAge so siblingAge can not be used as input into the module...

  • Write the Flowchart for the following programming problem based on the pseudocode below. Last year, a...

    Write the Flowchart for the following programming problem based on the pseudocode below. Last year, a local college implemented rooftop gardens as a way to promote energy efficiency and save money. Write a program that will allow the user to enter the energy bills from January to December for the year prior to going green. Next, allow the user to enter the energy bills from January to December of the past year after going green. The program should calculate the...

  • Look at this partial class definition, and then answer questions a - b below: Class Book...

    Look at this partial class definition, and then answer questions a - b below: Class Book    Private String title    Private String author    Private String publisher    Private Integer copiesSold End Class Write a constructor for this class. The constructor should accept an argument for each of the fields. Write accessor and mutator methods for each field. Look at the following pseudocode class definitions: Class Plant    Public Module message()       Display "I'm a plant."    End Module...

  • Convert the following pseudocode into C++ language. Declare X, Y, Z As Integer For (X =...

    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)

  • I have this code and need this to be written and applied with an array? How do I process this? Also What would I apply t...

    I have this code and need this to be written and applied with an array? How do I process this? Also What would I apply this with flowchart? Module main()   Call getDailyProfit()   Call calculateWeeklyProfit() Call main() Module getDailyProfit()   // Declare all variables and establish the array          Constant Real SIZE = 7          Declare String days[SIZE] = Sunday, Monday, Tuesday, Thursday. Friday, Saturday          Declare Real days          Declare Real number          Declare Real Index             //Prompt the user for profit information for Sunday          Display “How...

  • What is wrong with the following pseudocode? Declare Count As Integer Declare TheNumber As Integer Set...

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

  • Write a complete MIPS assembly language program that implements the following pseudocode. program h2 define global...

    Write a complete MIPS assembly language program that implements the following pseudocode. program h2 define global integer variables w, x, y, z -- in the .data section function main() SysPrintStr("Enter an integer >= 0 for w? ") w ← SysReadInt() SysPrintStr("Enter an integer >= 0 for x? ") x ← SysReadInt() SysPrintStr("Enter an integer < 0 for y? ") y ← SysReadInt() z ← 16(w + x) - (3 × -y mod 7) SysPrintStr("z = ") SysPrintInt(z) SysExit() end function...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT