Computer Science flowchart help?

In summary, the conversation discusses a sample exam with provided answers and a question about understanding flowcharts. The person explains that the first flowchart initializes variables and calls the "wat()" function, while the second flowchart includes "by value" and "by reference" modifiers. The output statement shows the desired answers. One example is given to explain how -6 is obtained for the variable K in the main program. The conversation concludes with the person expressing understanding after clarification.
  • #1
tinker99
8
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: 523
Technology news on Phys.org
  • #2
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.
 
  • #3
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?
 
  • #4
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.
 
  • #5
Thank you. I understand now:)
 

What is a flowchart and why is it important in computer science?

A flowchart is a visual representation of the steps or logic involved in solving a problem or completing a task using a computer program. It is important in computer science because it helps to organize and plan out the sequence of operations or decisions required to achieve a desired outcome.

How do I create a flowchart for a computer science problem?

To create a flowchart, you can use a software program specifically designed for flowcharting, such as Microsoft Visio or Lucidchart. You can also draw a flowchart by hand using symbols and arrows to represent different operations and decisions.

What are the common symbols used in a flowchart?

Some common symbols used in a flowchart include:

  • Start/End symbol: indicates the beginning and end of the flowchart
  • Input/Output symbol: represents the input or output of data
  • Process symbol: represents a specific operation or task
  • Decision symbol: indicates a condition or question that determines the next step in the flowchart
  • Connector symbol: connects different parts of the flowchart

Can I use a flowchart for any computer science problem?

Yes, a flowchart can be used for any computer science problem as long as it involves a sequence of operations or decisions. It is particularly useful for complex problems that require multiple steps or decisions to be made.

Can I test my computer program using a flowchart?

Yes, you can test your computer program using a flowchart by following the sequence of operations and decisions represented in the flowchart. This can help to identify any errors or bugs in the program and make necessary changes before implementation.

Similar threads

  • Programming and Computer Science
Replies
4
Views
1K
Replies
2
Views
790
  • Programming and Computer Science
Replies
7
Views
1K
  • Programming and Computer Science
Replies
1
Views
832
  • Programming and Computer Science
Replies
11
Views
1K
  • Programming and Computer Science
Replies
29
Views
3K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
1K
  • Programming and Computer Science
Replies
32
Views
3K
Replies
3
Views
108
  • Programming and Computer Science
Replies
15
Views
1K
Back
Top