COSC1315 Fundamentals of Programming
Instructor: Prof. Richard G. Baldwin
Assignment Number: 04
Non Object-Based program to pass a parameter by reference.
Making certain that you comply with the General Requirements, write a C++ program that meets the following specifications:
BEGIN WRITTEN SPECIFICATIONS
This program does not require the use of Object-Based Programming Syntax.
Start with the following source code.
// Beginning of program
#include <iostream>
using namespace std;
//-------------------------------------------------------//
Insert your new function named theFunction here.
//-------------------------------------------------------//
int main(){//Global main function.
cout << "In main" << endl;
int data = 20;
cout << "data = " << data << endl;
theFunction(data);
cout << "Back in main" << endl;
cout << "data = " << data << endl;
return 0;
}//end main function
// End of program
Do not modify the given code in any way.
Write a new function named theFunction and insert it between the dashed lines as indicated. When the program is executed using your new function, the screen output must match that shown below.
In main data = 20 Put your name here Back in main data = 40
END WRITTEN SPECIFICATIONS
As specified in the General Requirements, copy the above specifications, including the two lines of upper-case characters and paste the specifications into a comment block at the beginning of your source code file.
Note: Sometimes when copying C++ source code into HTML documents (like this one) the code will become corrupted. This is particularly true for code that involves left and right angle brackets such as in:
#include <iostream>
if(x <= y){
Although Prof. Baldwin has made an effort avoid such problems, it is possible that some corruption of source code may have occurred during the creation of these HTML documents. If you see anything that you believe might be corrupted source code, please notify Prof. Baldwin so that he can look into the problem, correct the code if necessary, and make all of the students aware of the problem.
-end-