140 likes | 269 Views
Computer Science. By: Erica Ligons. Compound Statement. A compound statement- is a unit of code consisting of zero or more statement also known as a block. Model Of Statement. Expression Statement. Compound Statement. Selection Statement. Statement. Labeled Statement.
E N D
Computer Science By: Erica Ligons
CompoundStatement • A compound statement- is a unit of code consisting of zero or more statement also known as a block
Model Of Statement Expression Statement Compound Statement Selection Statement Statement Labeled Statement Iterative Statement Jump Statement
Purpose of the Compound Statement • The compound statement allows it user to make groups of statements into a single chunk • Parts of Compound Statement Opening Brace Closing Brace
Functions • 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 Functions • Side effects- occurs when the is a change in the state of the program Aspects of a Side Effect • Accepting data from outside source • Sending data to monitor or file • Changing the value of a variable
Function Declaration • Function declaration- is done with a prototype declaration Purposes For Calling A Functions Name • When a function is declared • When it is called • When it is defined
Function 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 Passing Can pass parameter in two ways: • Pass by value- a copy of the data is created and placed in a local variable in the called function • Pass by reference- sends the address of a viable to the called function
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 type 2. The function name 3. Compound statement • Function body- contains declarations and statements for the functions
Selection • If else- use for two-way selections • Switch Selection- does the same as if else
Loops There are three types of loops • While loop- checks the value of a testing expression, pretest • For loop- it is a counter-control loop, pretest • Do-while loop- event controlled loop, but it is a posttest loop
Expression Statement Compound Statement Selection Statement Statement Labeled Statement Iterative Statement Jump Statement