CC112 Reviewer

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Module 6: Functions and Methods Flowchart Symbols

• Defining Functions • Terminal (oval) – start and end of the flowchart.


- involves specifying its name, parameters, and code block.
- Functions are created to encapsulate specific tasks. • Input/Output (parallelogram) – use whenever data
• Calling Functions – executes its code block at a specific point in is entered (input) or displayed (output).
your program. • Processing Box (rectangular) – use whenever data is
• Parameters – allow you to pass information into a function. It is being manipulated such as performing calculations.
defined within parentheses. • Decision – represent operation where there are two
• Return values – values that a function can provide as output possible selections, if, else if, else, true or false.
when it finishes executing.
• Using System; - directive that tells the compiler to include the • Flow line – indicate the direction of flow of control.
System namespace, which contains fundamental classes and
base types. • On-page connector – used to connect remote
• Class Program – defines a class named Program flowchart portion on the same page.
• Main method – entry point of the program • Off-page connector – used to connect remote
• Static void GreetUser() – declares a static method name flowchart portion on different pages.
GreetUser.
• Void return type – this function does not return any value.
• Static void Main () – inside Main, it calls the GreetUser()
method. START
• GreetUser(); - this line of code calls the GreetUser() method
from within the Main method.

Module 7: Functions and Methods Enter a first and second number


• Method overloading – defining multiple methods with the
same name but different parameters within the same class.
• Variable scope – where a program variable can be accessed.
• Lifetime – how long a variable exists during program execution. Adding the two number

Scope and Lifetime of Variables


Variable Scope
• Scope – defines where a variable is accessible within the code. If result
• Local Variables – scoped within a method and accessible only C=50
within that method.
• Global Variables – scoped at a broader level and accessible
throughout the class or program. Higher than 50 Lower than 50

Variable Lifetime
END
• Lifetime – duration for which a variable exists in memory.
• Local Variables – created when the method is called and
destroyed when the method exits.
• Global Variables – exist throughout the program’s execution.

Module 8: Exception Handling and Basic File I/O


• Exception Handling – enables the detection and management of
errors that may occur during program execution.
• Try – The block of code where exceptions may occur.
• Catch – Catches and handles the specified exception type.
• Finally – code that executes regardless of whether an exception
was thrown or not.

Common Exception Types


• System.Exception – the base class for all exceptions in C. Other
exception types derive from this class.
• System.IO.IOException – represents errors in I/O operations.
• System.DivideByZeroException – occurs when dividing by zero.
• System.NullReferenceException - occurs when trying to access a
member on a null object reference.

You might also like