Computer Science flowchart help?

AI Thread Summary
The discussion focuses on understanding flowcharts related to a computer science exam, specifically regarding the output of variables when using by value and by reference modifiers. The user seeks clarification on how the output values are derived from the flowcharts provided by the teacher. It is explained that passing variables by reference allows changes made within a function to affect the original variable in the calling program. An example illustrates that when the variable K is set to -2 and modified in the function, it results in a final output of -6. The user expresses improved understanding after the explanation.
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: 571
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:)
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
I am trying to run an .ipynb file and have installed Miniconda as well as created an environment as such -conda create -n <env_name> python=3.7 ipykernel jupyter I am assuming this is successful as I can activate this environment via the anaconda prompt and following command -conda activate <env_name> Then I downloaded and installed VS code and I am trying to edit an .ipynb file. I want to select a kernel, via VS Code but when I press the button on the upper right corner I am greeted...
Back
Top