Computer Science By: Erica Ligons Compound Statement A compound statement- block A compound...
-
Upload
flora-ryan -
Category
Documents
-
view
213 -
download
0
Transcript of Computer Science By: Erica Ligons Compound Statement A compound statement- block A compound...
Computer ScienceComputer Science
By: Erica Ligons
CompoundCompound StatementStatement
A compound statement-A compound statement- is a unit of code consisting of zero or more statement also known as a blockblock
Model Of StatementModel Of StatementExpression Statement
Compound Statement
Selection Statement
Labeled Statement
Iterative Statement
Jump Statement
Statement
Purpose of the Purpose of the Compound StatementCompound Statement
1. The compound statement allows it user to make groups of statements into a single chunk
2. Parts of Compound StatementOpening Brace
Closing Brace
FunctionsFunctions
Function-Function- a subroutine The “C” Program consist of many
functions, however, only one of the functions can be called a main
The main has the ability to allocate special tasks
The purpose of the function is to be able to receive one or more pieces of data
Side Effects of Side Effects of FunctionsFunctions
Side effects- occurs when the is a Side effects- occurs when the is a change in the state of the programchange in the state of the program
Aspects of a Side EffectAspects of a Side Effect1.1. Accepting data from outside sourceAccepting data from outside source
2.2. Sending data to monitor or fileSending data to monitor or file
3.3. Changing the value of a variableChanging the value of a variable
Function DeclarationFunction Declaration
Function declaration-Function declaration- is done with a prototype declaration
Purposes For Calling A Functions Name1. When a function is declared
2. When it is called
3. When it is defined
Function CallFunction Call
Function call- is used for the purpose of calling a function
Actual parameters-represent the values tat are to be sent to the called function
Parameter PassingParameter Passing
Can pass parameter in two ways:Pass by valuePass by value- a copy of the data is created
and placed in a local variable in the called function
Pass by reference-Pass by reference- sends the address of a viable to the called function
Function DefinitionFunction Definition
Function definition-Function definition- contains the code for for functions. It has two parts the header and function of the body.Function Header Parts
1.The return type2. The function name3. Compound statement
Function body-Function body- contains declarations and statements for the functions
Selection Selection
If else-If else- use for two-way selectionsSwitch Selection-Switch Selection- does the same as if else
LoopsLoops
There are three types of loopsWhile loop- checks the value of a testing
expression, pretestFor loop- it is a counter-control loop, pretestDo-while loop- event controlled loop, but it
is a posttest loop
Expression Statement
Compound Statement
Selection Statement
Labeled Statement
Iterative Statement
Jump Statement
Statement