Control Structures (Structured Programming) for controlling the procedural aspects of programming CS1110 – Kaminski.

Slides:



Advertisements
Similar presentations
While loops.
Advertisements

Control Structures Ranga Rodrigo. Control Structures in Brief C++ or JavaEiffel if-elseif-elseif-else-end caseinspect for, while, do-whilefrom-until-loop-end.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
ITEC113 Algorithms and Programming Techniques
5-1 Flow of Control Recitation-01/25/2008  CS 180  Department of Computer Science  Purdue University.
Program Design and Development
Chapter 4 Loops and Character Manipulation Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering İstanbul.
Statement-Level Control Structures Sections 1-4
ISBN Chapter 8 Statement-Level Control Structures.
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements II.
CONTROL STATEMENTS Lakhbir Singh(Lect.IT) S.R.S.G.P.C.G. Ludhiana.
Object Oriented Software Development
High-Level Programming Languages: C++
Flow Charting. Goals Create Algorithms using Flow Charting procedures. Distinguish between Flow Charting and Pseudocode. Top-Down Design Bottom-up Design.
Flow of Control. 2 Control Structures Control structure: An instruction that determines the order in which other instructions in a program are executed.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
CPS120 Introduction to Computer Science Iteration (Looping)
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
5-1 Repetition Statements Repetition statements allow us to execute a statement multiple times Often they are referred to as loops Like conditional statements,
CPS120: Introduction to Computer Science Decision Making in Programs.
COMPUTER PROGRAMMING. Iteration structures (loops) There may be a situation when you need to execute a block of code several number of times. In general,
Chapter 2 Pseudocode. Objectives To introduce common words, keywords and meaningful names when writing pseudocode To define the three basic control structures.
Visual Basic Programming
Saeed Ghanbartehrani Summer 2015 Lecture Notes #5: Programming Structures IE 212: Computational Methods for Industrial Engineering.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 5: Introduction to C: More Control Flow.
I Power Higher Computing Software Development High Level Language Constructs.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Sections © Copyright by Pearson Education, Inc. All Rights Reserved.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
Structured Programming The Basics. Control structures They control the order of execution What order statements will be done in, or whether they will.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Chapter 7: Repetition Structure (Loop) Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills.
Control structures in C by Dr P.Padmanabham Professor (CSE)&Director Bharat Institute of Engineering &Technology Hyderabad Mobile
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley.
While loops. Iteration We’ve seen many places where repetition is necessary in a problem. We’ve been using the for loop for that purpose For loops are.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Chad’s C++ Tutorial Demo Outline. 1. What is C++? C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for.
Loops causes program to execute the certain block of code repeatedly until some conditions are satisfied. Suppose you want to execute some code/s 10 times.
CS 106 Introduction to Computer Science I 02 / 15 / 2008 Instructor: Michael Eckmann.
Key Ideas from day 1 slides
Chapter 3: Decisions and Loops
CS-104 Final Exam Review Victor Norman.
PROGRAM CONTROL STRUCTURE
Warm-up Program Use the same method as your first fortune cookie project and write a program that reads in a string from the user and, at random, will.
Transition to Code Upsorn Praphamontripong CS 1110
Quick Test What do you mean by pre-test and post-test loops in C?
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
Lecturer CS & IT Department UOS MBDIN
Chapter 4 – Control Structures Part 1
Programming Fundamentals
Control Structures (Structured Programming) for controlling the procedural aspects of programming CS1110 – Kaminski.
Statement-Level Control Structures
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I – Exercises UTPA – Fall 2012 This set of slides is revised from lecture.
The University of Texas – Pan American
The University of Texas – Pan American
Introduction to Problem Solving and Control Statements
CS139 October 11, 2004.
Statement-Level Control Structures
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Chapter8: Statement-Level Control Structures April 9, 2019
Flow of Control.
Program Flow.
The structure of programming
More Loops Topics Counter-Controlled (Definite) Repetition
More Loops Topics Counter-Controlled (Definite) Repetition
Decision Structures if, if/else conditions
More Loops Topics Counter-Controlled (Definite) Repetition
Introduction to Classes and Objects
Presentation transcript:

Control Structures (Structured Programming) for controlling the procedural aspects of programming CS1110 – Kaminski

2 Programming Paradigms PP (Procedural Programming) OOP (Object Oriented Programming) but the body of OOP methods (& constructors & getters & setters) use PP

Procedural Programming Procedure (~= process = ~algorithm) Steps to solve a problem: 1st step 2nd step . . . last step

Object Oriented Programming a class includes: STORAGE for object’s ATTRIBUTES (= variables) - all objects of this class type HAVE these attributes - but each object has different VALUES for the attributes BEHAVIORS (= methods) - all objects of this class type can DO these behaviors (when requested) = “services” which this type of object can provide

A program consists of… 0) Header code (“just packaging info”) for [both PP programs & OOP programs] 0) Header code (“just packaging info”) for packages classes methods (& their parameters) import statement (to get classes from library)

1) Declarations request memory locations for data storage give name & data type to each possibly give an initial value (i.e., declare variables & constants & objects)

2) Action statements to be executed: operate on data Arithmetic (on numeric types) + - * / % Concatenate (string & … types) + move data around memory to memory (assignment) = memory to console (or file or window or …) keyboard (or file or window or …) to memory

3) Control statements decide the order that actions execute - next statement? - skip over some? - repeat some? - transfer control to elsewhere? - & return control back to “here”? NOTE: control STARTS at 1st statement in main method

Control Structures Traditionally: sequence – the default selection (decision, conditional execution) repetition (looping) Also: call method (& go back to where called) goto / break / return (& not go back)

Transfer control next statement (in physical sequence) (default) skip 1+ actions if some condition is FALSE or choose which action(s) to do next from SET of several choices, based on the value of some variable loop to do 1+ actions again (& again & again …) a fixed number of times or until some event happens i.e., when specified condition becomes True (or False) call a method & return “here” when it’s done method itself does some actions & it may itself transfer control further go to some statement & do NOT return “here” when done

Sequence start at the top do 1 statement after another, in order continue til the end

Selection (if-then-else) condition’s result (as true or false) determines which of 2 paths to follow (1 or more statements in each path)

Looping repeat 1+ statements based on whether a condition is true or false Condition may be: - event - a counter loop UNTIL condition becomes true, then stop looping WHILE condition is true, keep looping – stop looping when false

Types of Loops while loop (in most languages, incl. Java) for loop (in most languages, incl. Java) do until loop (in some languages, NOT Java) do while loop (in some languages, incl. Java) go to loop [bad programming practice] infinite loop with break [bad programming practice]

Combine the control structures Stack them or Nest them