college

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
}

  1. 👍
  2. 👎
  3. 👁
  1. 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.

    1. 👍
    2. 👎
  2. 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

    1. 👍
    2. 👎
  3. 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?

    1. 👍
    2. 👎
  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.

    1. 👍
    2. 👎
  5. 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

    1. 👍
    2. 👎
  6. . (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

    1. 👍
    2. 👎
  7. true

    1. 👍
    2. 👎

Respond to this Question

First Name

Your Response

Similar Questions

  1. Social Studies

    the XYZ affair outraged many americans. what was president john adams initial stance on how to handle the issue? Select 2. a. Adams asked Congress for a vote to declare war on France** b.Adams sent diplomats to negotiate with

  2. Programming

    Write a program (pseudocode) that would calculate and display the results for the multiplication table for values ranging from 1 to 100. This what I have so far: Declare X, Y, Z As Integer Write “10 x 10 Multiplication Table”

  3. programming

    Example Develop a pseudocode algorithm for a program that accepts each of the average marks of 10 students in a class and computes the sum and the average mark of the class. The program should display the average mark of the

  4. C++

    // Program: name of program // Author: your name // Date Written: date you began writing the program /* Abstract: Brief description of the program */ Include in-line comments in the body of your program. You can convert

  1. Imperialism and World War I

    what effect did john hay's open door policy letter have on the imperial powers of britain france germany russia and japan? A) It provoked the imperial powers to declare war on the United States. B) It caused the imperial powers to

  2. Is My Pseudocode Correct? - Programming

    I am supposed to make a pseudocode for a fat gram calculator. These are the instructions: Design a program that asks for the number of fat grams and calories in a food item. Validate the input as follows: - Make sure the number of

  3. Fat gram calculator

    Design a program that asks the user for the number of fat grams and calories in a food item. Validate the input as follows. Make sure the number of fat grams and calories are not less than 0. According to nutritional formulas, the

  4. social studys

    what was the purpose of the olive branch petition? A.to declare war on england B.to raise a colonial army C.to declare allegiance to the king of england D.to convince france to enter the war is it C?

  1. Social Studies

    What effect did John Hay's open door policy letters have on the imperial powers of Britain, France, Germany, Russia and Japan? A:It provoked the imperial powers to declare war on the united states B:It caused the imperial powers

  2. Intro to Programming PT1420

    What will the following pseudo code 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 ( Interger a, Real b) Set

  3. Civics

    11. The purpose of the petition sent to King George III by the First Continental Congress was to A. request a place in Parliament for colonial delegates. B. request that the king consider granting independence to the established

  4. C++, Coding, Programming

    Write a C++ program that declares a struct called course with the following attributes: int ID; string name; Then create a struct called student that contains the following attributes: int ID; string name; Vector of courses Write

You can view more similar questions or ask a new question.