Computer Science By: Erica Ligons Compound Statement A compound statement- block A compound statement- is a unit of code consisting of zero or more statement.

Slides:



Advertisements
Similar presentations
Spring Semester 2013 Lecture 5
Advertisements

C++ Statements represent the lowest-level building blocks of a program and it may be like:. A simple statement is a computation terminated by a semicolon.
Programming Languages and Paradigms The C Programming Language.
Chapter 7: User-Defined Functions II
CS0004: Introduction to Programming Repetition – Do Loops.
Homework Any Questions?. Statements / Blocks, Section 3.1 An expression becomes a statement when it is followed by a semicolon x = 0; Braces are used.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 5 - Functions Outline 5.1Introduction 5.2Program.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand basic loop concepts: ■ pretest loops and post-test loops ■ loop.
1 Chapter 4 Simple Selections and Repetitions INTRODUCTION The majority of challenging and interesting algorithms necessitate the ability to make.
Chapter 6: Function. Scope of Variable A scope is a region of the program and broadly speaking there are three places, where variables can be declared:
Functions in C. Function Terminology Identifier scope Function declaration, definition, and use Parameters and arguments Parameter order, number, and.
 Introduction Introduction  Types of Function Types of Function  Library function Library function  User defined function User defined function 
Beginning C++ Through Game Programming, Second Edition by Michael Dawson.
Flow of Control. 2 Control Structures Control structure: An instruction that determines the order in which other instructions in a program are executed.
C Functions Programmer-defined functions – Functions written by the programmer to define specific tasks. Functions are invoked by a function call. The.
C++ for Engineers and Scientists Second Edition Chapter 6 Modularity Using Functions.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. C How To Program - 4th edition Deitels Class 05 University.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Project 1 Due Date: September 25 th Quiz 4 is due September 28 th Quiz 5 is due October2th 1.
COMPUTER PROGRAMMING. Functions What is a function? A function is a group of statements that is executed when it is called from some point of the program.
CPS120: Introduction to Computer Science Decision Making in Programs.
1 Loops. 2 Topics The while Loop Program Versatility Sentinel Values and Priming Reads Checking User Input Using a while Loop Counter-Controlled (Definite)
CPS120: Introduction to Computer Science Functions.
1 Chapter 9 Additional Control Structures Dale/Weems.
Functions Top-down design Breaking a complex problem into smaller parts that we can understand is a common practice. The process of subdividing a problem.
CPS120: Introduction to Computer Science Lecture 14 Functions.
A First Book of ANSI C, Fourth Edition1 Functions for Modularity 04/24/15.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Built-In and user-Defined functions Software Design Concepts Lecture IV Dr. Sothy Vignarajah.
ECE 103 Engineering Programming Chapter 18 Iteration Herbert G. Mayer, PSU CS Status 7/19/2015 Initial content copied verbatim from ECE 103 material developed.
Covenant College November 27, Laura Broussard, Ph.D. Professor COS 131: Computing for Engineers Chapter 5: Functions.
FUNCTIONS IN C++. DEFINITION OF A FUNCTION A function is a group of statements that together perform a task. Every C++ program has at least one function,
JavaScript, Fourth Edition
1 Methods Introduction to Methods Passing Arguments to a Method More About Local Variables Returning a Value from a Method Problem Solving with Methods.
CSCI 171 Presentation 6 Functions and Variable Scope.
Functions in C CSE 2451 Rong Shi. Functions Why use functions? – Reusability Same operation, different data – Abstraction Only need to know how to call.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
1 MORE ON MODULAR DESIGN: MODULE COMMUNICATIONS. 2 WHEN A FUNCTION IS INVOKED, MEMORY IS ALLOCATED LOCALLY FOR THE FORMAL PARAMETERS AND THE VALUE OF.
CISC105 – General Computer Science Class 8 – 06/28/2006.
Repetition Repetition allows you to repeat an operation or a series of operations many times. This is called looping and is one of the basic structured.
Repetition Statements (Loops). 2 Introduction to Loops We all know that much of the work a computer does is repeated many times. When a program repeats.
Introduction to Programming Lecture 6. Functions – Call by value – Call by reference Today's Lecture Includes.
Functions in C++ Top Down Design with Functions. Top-down Design Big picture first broken down into smaller pieces.
Presentation By :- Nikhil R. Anande ( ) Electronic & Communication Engineering. 3 nd Year / 5 th Semester FACULTY GUIDE : RAHIUL PATEL SIR MICROCONTROLLER.
Introduction to Programming
C Functions -Continue…-.
Unit-1 Introduction to Java
Loops in Java.
Statements (6 of 6) A statement causes an action to be performed by the program. It translates directly into one or more executable computer instructions.
Functions Review.
FIGURE 4-10 Function Return Statements
Function There are two types of Function User Defined Function
Programming Fundamentals Lecture #7 Functions
Topics discussed in this section:
Programmazione I a.a. 2017/2018.
C++ for Engineers and Scientists Second Edition
Chapter 5 - Functions Outline 5.1 Introduction
Introduction to Functions
Chapter 6 Repetition Objectives ❏ To understand basic loop concepts:
FIGURE 4-10 Function Return Statements
4-2 Functions in C In C, the idea of top–down design is done using functions. A C program is made of one or more functions, one and only one of which.
Chapter 4 Functions Objectives
FIGURE 4-10 Function Return Statements
Chapter 9: Value-Returning Functions
4-2 Functions in C In C, the idea of top–down design is done using functions. A C program is made of one or more functions, one and only one of which.
Flow of Control.
FIGURE 4-10 Function Return Statements
Parameters and Arguments
Presentation transcript:

Computer Science By: Erica Ligons

Compound Statement A compound statement- block 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 Labeled Statement Iterative Statement Jump Statement Statement

Purpose of the Compound Statement 1. The compound statement allows it user to make groups of statements into a single chunk 2. Parts of Compound Statement Opening Brace Closing Brace

Functions 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 Functions Side effects- occurs when the is a change in the state of the program Side effects- occurs when the is a change in the state of the program Aspects of a Side Effect 1. Accepting data from outside source 2. Sending data to monitor or file 3. Changing the value of a variable

Function Declaration Function declaration- Function declaration- is done with a prototype declaration Purposes For Calling A Functions Name 1. When a function is declared 2. When it is called 3. 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 Pass 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 Definition Function Function definition- definition- contains the code 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 Function body- body- contains declarations and statements for the functions

Selection If else- If else- use for two-way selections Switch Selection- 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 Labeled Statement Iterative Statement Jump Statement Statement