Computer Science flowchart help?

Click For Summary

Discussion Overview

The discussion revolves around understanding flowcharts related to a sample exam in computer science, specifically focusing on parameters (actual and formal) and the output generated by a function. The scope includes conceptual clarification and technical explanation of flowchart logic.

Discussion Character

  • Conceptual clarification, Technical explanation

Main Points Raised

  • One participant expresses confusion about interpreting flowcharts and obtaining outputs from them.
  • Another participant explains the initialization of variables and the significance of by value and by reference modifiers in the flowchart.
  • A participant seeks clarification on specific output values (-6 for k, 8 for s, and -8 for p) in the context of the flowchart.
  • A further explanation is provided regarding how the value of k is derived through the passing of variables by reference, detailing the calculation involved.
  • One participant indicates improved understanding after the explanations.

Areas of Agreement / Disagreement

Participants appear to agree on the mechanics of how parameters are passed and how outputs are derived, though initial confusion exists regarding the flowchart outputs. The discussion does not present any significant disagreements.

Contextual Notes

Some assumptions about the flowchart structure and the specific function behavior may not be fully articulated, which could affect understanding. The discussion does not resolve all potential ambiguities in the flowchart interpretation.

Who May Find This Useful

Students preparing for computer science exams, particularly those focusing on flowchart logic and parameter passing in programming.

tinker99
Messages
8
Reaction score
0
I have a sample exam in which the teacher provided the answers for, but I am not understanding these flowcharts. I understand actual parameters and formal parameters, but not how I would get the output. Can someone help explain this to me? I have uploaded one of the questions with the answers.
 

Attachments

  • CS exam 1.JPG
    CS exam 1.JPG
    30 KB · Views: 586
Technology news on Phys.org
We'll start at start, the first few stmts initialize variables, the next calls the wat() function.

So shift over to the second flowchart. Pay attention to the by value and by reference modifiers. By reference means the variable will be changed in the calling program so you need to remember that when you finish with the wat() function. The output stmt prints the answers which the teacher wants to see.
 
Thank you. I understand a little better now. I am just confused as to how we get -6 for k in the main and 8 for s and -8 for p in the method?
 
tinker99 said:
how we get -6 for k in the main
One example. In main, K is set to -2. It is passed by reference to B in WAT, so any change of B in WAT actually changes K. B is changed to B-S=(-2)-4 = -6. That is the final output.
 
Thank you. I understand now:)
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
Replies
2
Views
1K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 32 ·
2
Replies
32
Views
5K
Replies
29
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K