PDA

View Full Version : I don't understand english :(



Peegee
11-02-2004, 10:31 AM
There's a programming assignment I have to do, but I don't understand what it's asking me to do. I don't need help coding, just to be told what it expects me to do in order to receive input. Actually I'm just looking to verify what I think:


You are required to write two C programs using top-down design approach (that is, using functions as specified in the given structure chart) for the problem described below. The requirements of the two programs are as follows:

1) The first program should not use any global variables, must pass all input parameters using call-by-value parameters and must pass all output parameters using call-by-reference parameters.

2) The second program should declare all main program input and output variables globally and should not pass any parameters in the function calls. Note that a function can still declare needed local variables.

3) You are also required to show tracing of your two programs with test data to test for correctness of your solutions. Do not give other problem solving steps.

Problem Description:

In course 60-140 offered at the University of Windsor, your instructor evaluates student performance based on 6 assignments, 2 quizzes, a lab exercise mark, a lab exam mark, a class participation mark, a midterm test and a final examination mark.

As shown in the course outline for the course, the total course mark of 100% is distributed as follows:



COURSE EVALUATION

<table><tr><td rowspan="2">Work Mark (out of 100%)</td></tr>
<tr><td>Assignments</td><td>10%</td></tr><tr>
<td>2 Quizzes</td><td>15%</td></tr><tr><td>Lab Exercises and Attendance</td><td>5%</td></tr><tr><td>Lab Examination</td><td>5%</td></tr><tr><td>Class Participation</td><td>5%</td></tr><tr><td>Midterm Test</td><td>15%</td></tr><tr><td>Final Examination</td><td>45%</td></tr></table>
--

Am I supposed to write two different programs using different means to pass variables? One using global variables and the other using call by value/call by reference input/output? How do I go about doing the second? If I use call by value, the function call will be functName (a,b,c);, but what happens to the output? Can I still use *a = grade * 0.1; or whatever?

Flying Mullet
11-02-2004, 03:58 PM
Your assignment wants you to write the same program two different ways, one by passing in parameters to the functions and another one using global variables.

So for the global program you will declare your variables globally and reference them in all of your methods and such just like they are local variables.

As for the parameter program, your instructor wants you to use call-by-value parameters and must pass all output parameters using call-by-reference parameters. Remember that you pass in parameters by reference with a '&' (pointer). So if you have the following code:

int a = 1;
int b = 2;
testMethod(a, b);

public void testMethod(int a, int &b)
{
a = 3;
b = 4;
}

That after the method is called a will still be 1 but b will be 4 because a was passed by value and b was passed by reference.

Hope this helps.

p.s. I don't remember the syntax of passing by reference anymore so I don't know if that ampersand is in the right place.

Peegee
11-02-2004, 04:14 PM
That's enough for me to understand. Thanks so much. While I was waiting for the answer I finished the global part. Now to 'tweak' it so it does the other thing.

Marvellous! Isn't programming easy?

Dr Unne
11-02-2004, 05:43 PM
Marvellous! Isn't programming easy?

perl -le 'print map{chr$_}split/\W/,"78+111=46"'

Samuraid
11-03-2004, 12:00 AM
if ($question !~ m/bb|[^b]{2}/i) { die(); }

Peegee
11-03-2004, 07:18 PM
:( :(