100% Zufriedenheitsgarantie Sofort verfügbar nach Zahlung Sowohl online als auch als PDF Du bist an nichts gebunden 4.2 TrustPilot
logo-home
Zusammenfassung

COS132 Chapter 6 Summary

Bewertung
-
Verkauft
-
seiten
7
Hochgeladen auf
20-04-2022
geschrieben in
2021/2022

Very detailed summaries.

Hochschule
Kurs









Ups! Dein Dokument kann gerade nicht geladen werden. Versuch es erneut oder kontaktiere den Support.

Verknüpftes buch

Schule, Studium & Fach

Hochschule
Kurs

Dokument Information

Gesamtes Buch?
Ja
Hochgeladen auf
20. april 2022
Anzahl der Seiten
7
geschrieben in
2021/2022
Typ
Zusammenfassung

Themen

Inhaltsvorschau

COS132 Chapter 6



COS 132
CHAPTER 6 – FUNCTIONS

UNIT 6.1- FOCUS ON SOFTWARE ENGINEERING: MODULAR PROGRAMMING

A program may be broken up into manageable functions.

A function = collection of statements that perform a specific task.

- We have experienced functions in two ways:
o Creating “main” in every program
o Library functions
 Pow
 Strcmp

Using functions can be called divide and conquer as a large problem is divided.

Benefit of using functions is code reuse.

UNIT 6.2 – DEFINING AND CALLING FUNCTIONS

Function call = statement that causes a function to execute, a function definition contains the statements that make up the function.

When creating a function, you must write its definition, all function definitions have the following parts:




VOID FUNCTIONS
Some functions simply perform one or more statements, and then terminate – they are known as void functions. This means the
function does not return a value to the part of the program that executed it. Also notice the function has no return statement


CALLING A FUNCTION
Function main is automatically called when a program starts, but all other functions must be executed by function call statements.

Function header ---- void functionName()

, COS132 Chapter 6

Function call --- functionName();

UNIT 6.3 – FUNCTION PROTOTYPES / FUNCTION DECLARATIONS

A function prototype eliminates the need to place a function definition before all calls to the function.

Before the complier encounters a call to a particular function, it must already know the function’s return type, the number of
parameters it uses, and the type of each parameter. One way of ensuring that the compiler has this info is to place the function
definition before all calls to that function.

Another method is to declare the function w a function prototype, (void functionName(); ) the prototype looks similar to the
function header, except there is a semicolon at the end.

Function prototypes are usually placed near the top of a program so the compiler will encounter them before any function calls.

UNIT 6.4 – SENDING DATA INTO A FUNCTION

When a function is called, the program may send values into the function. These values are called arguments.

The values that are passed into a function are called arguments, and the variables that receive those values are called parameters.
There are several variations of these terms in use. Some call the arguments actual parameters and call the parameters formal
parameters. Others use the terms actual argument and formal argument. Regardless of which set of terms you use, it is important to
be consistent




If you pass an argument whose type is not the same as the parameter’s type, the argument will be promoted or demoted
automatically.

Parameters have a scope – limited to the body of the function that uses it.

UNIT 6.5 – PASSING DATA BY VALUE

When an argument is passed into a parameter, only a copy of the arguments value is passed. Changes to the parameter do not affect
the OG argument.

Parameters are special-purpose variables that are defined inside the parentheses of a function definition. They are separate and
distinct from the arguments that are listed inside the parentheses of a function call. The values that are stored in the parameter
variables are copies of the arguments. Normally, when a parameter’s value is changed inside a function, it has no effect on the
original argument.

UNIT 6.6 – FOCUS ON SOFTWARE ENGINEERING: USING FUNCTIONS IN A MENU-DRIVEN PROGRAM

Functions are ideal for use in menu-driven programs, when the user selects an item from a menu, the program can call the
appropriate function.
4,63 €
Vollständigen Zugriff auf das Dokument erhalten:

100% Zufriedenheitsgarantie
Sofort verfügbar nach Zahlung
Sowohl online als auch als PDF
Du bist an nichts gebunden


Ebenfalls erhältlich im paket-deal

Lerne den Verkäufer kennen

Seller avatar
Bewertungen des Ansehens basieren auf der Anzahl der Dokumente, die ein Verkäufer gegen eine Gebühr verkauft hat, und den Bewertungen, die er für diese Dokumente erhalten hat. Es gibt drei Stufen: Bronze, Silber und Gold. Je besser das Ansehen eines Verkäufers ist, desto mehr kannst du dich auf die Qualität der Arbeiten verlassen.
jennamortonx IIE Varsity College
Folgen Sie müssen sich einloggen, um Studenten oder Kursen zu folgen.
Verkauft
18
Mitglied seit
3 Jahren
Anzahl der Follower
1
Dokumente
49
Zuletzt verkauft
5 Jahren vor

4,0

1 rezensionen

5
0
4
1
3
0
2
0
1
0

Kürzlich von dir angesehen.

Warum sich Studierende für Stuvia entscheiden

on Mitstudent*innen erstellt, durch Bewertungen verifiziert

Geschrieben von Student*innen, die bestanden haben und bewertet von anderen, die diese Studiendokumente verwendet haben.

Nicht zufrieden? Wähle ein anderes Dokument

Kein Problem! Du kannst direkt ein anderes Dokument wählen, das besser zu dem passt, was du suchst.

Bezahle wie du möchtest, fange sofort an zu lernen

Kein Abonnement, keine Verpflichtungen. Bezahle wie gewohnt per Kreditkarte oder Sofort und lade dein PDF-Dokument sofort herunter.

Student with book image

“Gekauft, heruntergeladen und bestanden. So einfach kann es sein.”

Alisha Student

Häufig gestellte Fragen