Jiskha Homework Help
SATURDAY
November 21, 2009
SCHOOL SUBJECTS
- Art
- Business
- Computers
- English
- Foreign Languages
- Health
- Home Economics
- Math
- Music
- Physical Education
- Science
- Social Studies
GRADE LEVELS
- Preschool
- Kindergarten
- Elementary School
- 1st Grade
- 2nd Grade
- 3rd Grade
- 4th Grade
- 5th Grade
- 6th Grade
- 7th Grade
- 8th Grade
- High School
- 9th Grade
- 10th Grade
- 11th Grade
- 12th Grade
- College
- Adult Education
Post a New Question | Current Questions | Chat With Live Tutors

Homework Help Forum: college

Posted by timi on Sunday, November 1, 2009 at 6:14pm.

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
}

  • Programming/math, not "college" - Writeacher, Sunday, November 1, 2009 at 6:49pm

    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.

  • college - Quidditch, Sunday, November 1, 2009 at 7:10pm

    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

  • college - MathMate, Sunday, November 1, 2009 at 7:20pm

    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?


  • college - MathMate, Sunday, November 1, 2009 at 7:24pm

    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.

Answer this Question

First Name:
School Subject:
Answer:

For Further Reading

SEARCH

COMMUNITY
FEATURES
- Live Tutors
- Net Riddle
- Reference
- Search