Computer Science Homework Solutions
Problem
#229600

Design a module named getNumber which uses a reference parameter variable to accept an Integer argument. The module should prompt the user to enter a number and then store the input in the reference parameter variable.

Design a module named getNumber which uses a reference parameter variable to accept an Integer argument. The module should prompt the user to enter a number and then store the input in the reference parameter variable.

I'm having difficulty comprehending the concept of a reference variable.  I've written my module below, however I'm unsure if I'm correct. I respectfully request your review and suggestions.


Module main ()
//Declare and initialize variable
Declare Integer = 99
//Display the value in variable
Display "x is set to", x

//Pass variable to getNumber
Call getNumber (x)

//Display the values now
Display "Enter a number"
Input number
Display "x is set to", x
End Module

Module getNumber (Integer Ref value)
Set value = 0
End Module


Solution Summary

Solution also gives a corresponding C++ implementation to see the reference variable in action.

Solution
What is this?
By OTA - Overall OTA Rating
Purchase Cost Now
$2.19 CAD (was ~$11.97)
Included in Download
  • Plain text response
  • Attached file(s):
    • 229600.cpp
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • Semantics and Runtime Environment - What is the difference between using a pass by value and pass by reference with a compiler?
  • C++ Programming (User Defined Functions) - See attach file.
  • Linux: Explain the function - Using the following script: #!/bin/bash #This is a shell script echo $# echo $0 echo $1 echo $2 echo $3 echo $* name1=$1 #name2=$2 echo $name1 "is the first parameter" echo $name2 "is th ...
  • Create a C sharp program that includes the following requirements - 1. A class definition for a Date class that contains three integer data members: month, day, and year. 2. One constructor that assigns the date 1/1/2000 to any new object that does not rec ...
  • c++ - arrays - Create a C++ class that implements a "safe" array, where the arrays bounds are checked before accessing its elements. The class constructor must accept an integer parameter and create a dynamic array ...
Browse