Ms. Payne, WCSS. This is very much like asking a question, and having a yes/no answer (also known a true/false). The general structure for this is:

Size: px
Start display at page:

Download "Ms. Payne, WCSS. This is very much like asking a question, and having a yes/no answer (also known a true/false). The general structure for this is:"

Transcription

1 The Decision Structure The repetition (looping) structure discussed previously is a very important structure because it allows the programmer to instruct the computer to do something more than once. The decision structure is also very powerful. A decision structure is used to determine if a specific action should be taken. It allows different actions to be taken depending on the circumstance. Decision structures have four parts. If, then,, end if. Lets look at an example written in plain English: if it is after midnight then go to bed keep partying end if This is very much like asking a question, and having a yes/no answer (also known a true/false). The general structure for this is: if some condition then - statements to be executed when the condition is true. - statements to be executed when the condition is false end if

2 Here s an example where the user is asked the Capital of Ontario. answer = "" exit = 0 While exit = 0 TextWindow.WriteLine("Please enter in the capital of Ontario") answer = TextWindow.Read()'reads user input (can be with spaces) if answer = "Toronto" then TextWindow.WriteLine("Correct") exit = 1 TextWindow.WriteLine("Try again") endif EndWhile 'exits loop when answer is correct 'loop repeats until correct answer Here is another example where a user entered in two numbers and then entered the sum. The program then checks to see if their sum is correct. TextWindow.WriteLine("Please enter the first number:") number1 = TextWindow.Read() TextWindow.WriteLine("Please enter the second number:") number2 = TextWindow.Read() TextWindow.WriteLine("Please enter the sum of "+number1+" and "+number2+":") total = TextWindow.Read() if total = number1 + number2 then TextWindow.WriteLine("Congratulations, that is correct") TextWindow.WriteLine("Check your answer.") Endif

3 If you want to do more than one comparison you use if for every check after the first if. For example, here s a program that has the user enter in a number, and then it checks to see if the number is positive, negative or zero. TextWindow.WriteLine("Please enter a number:") number = TextWindow.Read() if number > 0 then TextWindow.WriteLine("positive") if number < 0 then TextWindow.WriteLine("negative") TextWindow.WriteLine("zero") endif Here I have also introduced different ways to compare things. You use the following syntax to computer two values in an if--then statement: < less than > greater than <= less than or equal to >= greater than or equal to <> not equal

4 Activity #1: Write a program that has the user enter in their age, and then based on their age you output a movie price. This program should repeat for multiple users. Here is the pseudo code: Get users age If they are 65 or older Pay $3.00 as you are a senior If they are 20 or older Pay $6.00 as they are an adult If they are 14 or older Pay $3.00 as they are a student If they are younger then 14 Pay $2.00 as they are a child. Activity #2: Create a conditional if statement that allows the user to pick a favourite colour, and then will output a circle of that colour. Activity #3: Create a multiple choice quiz or game using If Statements

5 AND and OR We can use AND and OR statements in our if-then- statements to look at multiple ranges or options for each action. For example, a way to complete the previous activity would be to use and statements to declare an age range. In this case I have used two comparisons split by an and but it is possible to use more than two as well. TextWindow.WriteLine("Please enter an age:") age = TextWindow.Read() If age>=0 And age<13 Then TextWindow.WriteLine("You are a child.") ElseIf age>=13 and age<20 then TextWindow.WriteLine("You are a teen.") if age>=20 and age <65 then TextWindow.WriteLine("You are an adult.") if age>65 and age<=115 then TextWindow.WriteLine("You are a senior.") Else TextWindow.WriteLine("Invalid age.") EndIf

6 In many cases we would also like to do comparisons where a reaction happens in the case of many individual options. For example, proper coding would be to check each possible user input ( a, A ) for the following questions. Start: TextWindow.WriteLine("Pick a favourite colour: ") TextWindow.WriteLine("a) Red") TextWindow.WriteLine("b) Blue") TextWindow.WriteLine("c) Green") TextWindow.WriteLine("d) Yellow") TextWindow.WriteLine("e) Orange") Choice = TextWindow.Read() If Choice = "a" Or Choice = "A" Then Color = "red" ElseIf Choice = "b" Or Choice = "B" then Color = "blue" ElseIf Choice = "c" Or Choice = "C" then Color = "green" ElseIf Choice = "d" Or Choice = "D" then Color = "yellow" ElseIf Choice = "e" Or Choice = "E" then Color = "orange" Else TextWindow.WriteLine("Try Again") Program.Delay(2000) TextWindow.Clear() Goto Start EndIf TextWindow.Hide() GraphicsWindow.Show() GraphicsWindow.Height = 400 GraphicsWindow.Width = 400 GraphicsWindow.BrushColor = Color Circle = Shapes.AddEllipse(100,100) Shapes.Move(Circle,150,150) Even better programming would be to check for all possibilities ( a, A, red, Red ) such as the following line: If Choice = "a" Or Choice = "A" Or Choice = "red" Or Choice = "Red" Then

7 Activity #1: Develop a program that compares the # of hours of playing video games a week against the following scale: less than 2 hours is "too little" between 2 hours and 4 hours is "normal" between 4 hours and 8 is "excessive" more than 8 hours is "ridonculous!" Activity #2: Write a program that give the user feedback of "higher" or "lower" until the user correctly guesses a randomly generated number between 1 and 100. Activity #3: Create a simple trivial-pursuit-type game with questions that keeps a score as the user works through the game.

Repetition Algorithms

Repetition Algorithms Repetition Algorithms Repetition Allows a program to execute a set of instructions over and over. The term loop is a synonym for a repetition statement. A Repetition Example Suppose that you have been

More information

Repetition Structures

Repetition Structures Repetition Structures Chapter 5 Fall 2016, CSUS Introduction to Repetition Structures Chapter 5.1 1 Introduction to Repetition Structures A repetition structure causes a statement or set of statements

More information

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution. Repetition Structures Introduction to Repetition Structures Chapter 5 Spring 2016, CSUS Chapter 5.1 Introduction to Repetition Structures The Problems with Duplicate Code A repetition structure causes

More information

RELATIONAL AND LOGICAL OPERATORS

RELATIONAL AND LOGICAL OPERATORS Contents RELATIONAL AND LOGICAL OPERATORS... Relational Operators... Logical Operators... Using Relational and Logical Operators with Scalars... 2 Using Relational Operators with Numerical Arrays... 5

More information

5. Selection: If and Switch Controls

5. Selection: If and Switch Controls Computer Science I CS 135 5. Selection: If and Switch Controls René Doursat Department of Computer Science & Engineering University of Nevada, Reno Fall 2005 Computer Science I CS 135 0. Course Presentation

More information

Debugging in Small Basic is the process of analysing a program to detect and fix errors or improve functionality in some way.

Debugging in Small Basic is the process of analysing a program to detect and fix errors or improve functionality in some way. How to Debug Introduction Debugging in Small Basic is the process of analysing a program to detect and fix errors or improve functionality in some way. In order to debug a program it must first compile

More information

Programming Logic and Design Sixth Edition

Programming Logic and Design Sixth Edition Objectives Programming Logic and Design Sixth Edition Chapter 4 Making Decisions In this chapter, you will learn about: Evaluating Boolean expressions to make comparisons The relational comparison operators

More information

Selection Control Structure CSC128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING

Selection Control Structure CSC128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING Selection Control Structure CSC128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING MULTIPLE SELECTION To solve a problem that has several selection, use either of the following method: Multiple selection nested

More information

CHAPTER 2 PROBLEM SOLVING TECHNIQUES. Mr Mohd Hatta Bin Hj Mohamed Ali Computer Programming BFC2042

CHAPTER 2 PROBLEM SOLVING TECHNIQUES. Mr Mohd Hatta Bin Hj Mohamed Ali Computer Programming BFC2042 CHAPTER 2 PROBLEM SOLVING TECHNIQUES Mr Mohd Hatta Bin Hj Mohamed Ali Computer Programming BFC2042 Software Engineering vs Problem Solving Software Engineering - A branch of Computer Science & provides

More information

Pseudocode. ARITHMETIC OPERATORS: In pseudocode arithmetic operators are used to perform arithmetic operations. These operators are listed below:

Pseudocode. ARITHMETIC OPERATORS: In pseudocode arithmetic operators are used to perform arithmetic operations. These operators are listed below: Pseudocode There are 3 programming/pseudocode constructs: 1. Sequence: It refers that instructions should be executed one after another. 2. Selection: This construct is used to make a decision in choosing

More information

FLOW CHART AND PSEUDO CODE

FLOW CHART AND PSEUDO CODE FLOW CHART AND PSEUDO CODE Flowchart A Flowchart is a pictorial representation of an algorithm. The First flowchart is made by John Von Newman in 1945. It is a symbolic diagram of operation sequence, dataflow,

More information

Year 8 Computing Science End of Term 3 Revision Guide

Year 8 Computing Science End of Term 3 Revision Guide Year 8 Computing Science End of Term 3 Revision Guide Student Name: 1 Hardware: any physical component of a computer system. Input Device: a device to send instructions to be processed by the computer

More information

SNS COLLEGE OF ENGINEERING

SNS COLLEGE OF ENGINEERING SNS COLLEGE OF ENGINEERING DEPARTMENT OF CSE Presented By Thillaiarasu.N SCRAMBLE 2 Solution 3 What is Pseudocode? 4 Consists of: Short Readable Formally styled English language Used for: Explaining the

More information

Table of Contents. Lesson Lesson Lesson Lesson Lesson Lesson Lesson

Table of Contents. Lesson Lesson Lesson Lesson Lesson Lesson Lesson P a g e 1 Table of Contents Lesson 1... 3 Lesson 2... 9 Lesson 3...13 Lesson 4... 17 Lesson 5... 23 Lesson 6...27 Lesson 7... 30 P a g e 2 P a g e 3 Hello World! Welcome to your first lesson! In this lesson,

More information

ECOR Come to the PASS workshop with your mock exam complete. During the workshop you can work with other students to review your work.

ECOR Come to the PASS workshop with your mock exam complete. During the workshop you can work with other students to review your work. It is most beneficial to you to write this mock midterm UNDER EXAM CONDITIONS. This means: Complete the midterm in 1.5 hour(s). Work on your own. Keep your notes and textbook closed. Attempt every question.

More information

Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object

Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object CS1046 Lab 5 Timing: This lab should take you approximately 2 hours. Objectives: By the end of this lab you should be able to: Recognize a Boolean variable and identify the two values it can take Calculate

More information

Java Outline (Upto Exam 2)

Java Outline (Upto Exam 2) Java Outline (Upto Exam 2) Part 4 IF s (Branches) and Loops Chapter 12/13 (The if Statement) Hand in Program Assignment#1 (12 marks): Create a program called Ifs that will do the following: 1. Ask the

More information

By John, Kunal, Murid, Zamir. Turing Guide Repetition

By John, Kunal, Murid, Zamir. Turing Guide Repetition By John, Kunal, Murid, Zamir. Turing Guide Repetition Table of Contents Title Page.1 Table of Contents...2 A Brief History of Turing. 3 What is Repetition.. 4 Infinite Loops...5 Conditional Loops.. 5-6

More information

NEA sample solution Task 2 Cows and bulls (solution 2) GCSE Computer Science 8520 NEA (8520/CA/CB/CC/CD/CE)

NEA sample solution Task 2 Cows and bulls (solution 2) GCSE Computer Science 8520 NEA (8520/CA/CB/CC/CD/CE) NEA sample solution Task 2 Cows and bulls (solution 2) GCSE Computer Science 8520 NEA (8520/CA/CB/CC/CD/CE) 2 Introduction The attached NEA sample scenario solution is provided to give teachers an indication

More information

Algorithms, Part 2 of 3. Topics Problem Solving Examples Pseudocode Control Structures

Algorithms, Part 2 of 3. Topics Problem Solving Examples Pseudocode Control Structures Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode Control Structures 1 Problem Solving Decode this sentence: Pdeo eo pda yknnayp wjosan. We have just come up with a specific solution to

More information

Looping Subtasks. We will examine some basic algorithms that use the while and if constructs. These subtasks include

Looping Subtasks. We will examine some basic algorithms that use the while and if constructs. These subtasks include 1 Programming in C Looping Subtasks We will examine some basic algorithms that use the while and if constructs. These subtasks include Reading unknown quantity of data Counting things Accumulating (summing)

More information

SmallBasicOverview. RCHS Computer Club

SmallBasicOverview. RCHS Computer Club SmallBasicOverview RCHS Computer Club Constants and Variables 2 kinds of constants Numeric: e.g. 5, 42; but not in scientific notation String: e.g. Hello ; always in double-quotes Variables Give a name

More information

Loops (while and for)

Loops (while and for) Loops (while and for) CSE 1310 Introduction to Computers and Programming Alexandra Stefan 1 Motivation Was there any program we did (class or hw) where you wanted to repeat an action? 2 Motivation Name

More information

RETURN X return X Returning a value from within a function: computes the value of variable exits the function and returns the value of the variable

RETURN X return X Returning a value from within a function: computes the value of variable exits the function and returns the value of the variable STUDENT TEACHER CLASS WORKING AT GRADE TERM TARGET YEAR TARGET Pseudocode Python Description BEGIN END Identifies the start of a program Identifies the end of a program READ X, Y, Z input() Identifies

More information

CSCI 1226 A Test #1. Wednesday, 10 October, 2018 Name: Student #: General Instructions Read and follow all directions carefully.

CSCI 1226 A Test #1. Wednesday, 10 October, 2018 Name: Student #: General Instructions Read and follow all directions carefully. General Instructions Read and follow all directions carefully. CSCI 1226 A Test #1 Wednesday, 10 October, 2018 Name: Student #: When writing programs or program segments, use the conventions used in the

More information

MICROPROCESSOR SYSTEMS INTRODUCTION TO PYTHON

MICROPROCESSOR SYSTEMS INTRODUCTION TO PYTHON MICROPROCESSOR SYSTEMS INTRODUCTION TO PYTHON Table of contents 2 1. Learning Outcomes 2. Introduction 3. The first program: hello world! 4. The second program: hello (your name)! 5. More data types 6.

More information

Logging in & Taking a Course

Logging in & Taking a Course Logging in & Taking a Course The image to the right is an image of our Log in page. To access your training Log in to your account by visiting https://training.ipced.com/ and entering in your username

More information

Control Structure: Selection

Control Structure: Selection Control Structure: Selection Knowledge: Understand various concepts of selection control structure Skill: Be able to develop a program containing selection control structure Selection Structure Single

More information

IDENTIFY WAYS OF REPRESENTING ALGORITHMS.

IDENTIFY WAYS OF REPRESENTING ALGORITHMS. IDENTIFY WAYS OF REPRESENTING ALGORITHMS. OBJECTIVES: Identify ways of representing algorithms: Content Representation of algorithms as Pseudocode or Flowcharts; use of flow chart symbols: input/output

More information

Add Binary Numbers What is the largest decimal number you can represent using 3 bits?

Add Binary Numbers What is the largest decimal number you can represent using 3 bits? 1 2 Quiz1 Question Add Binary Numbers 1 0 1 1 a) 1 0 1 0 1 0 +1 0 0 0 b) 0 1 0 0 1 1 1 0 0 1 1 c) 0 1 0 0 0 1 d) 0 1 0 1 1 1 e) none 001011 001000 010011 Quiz1 question What is the largest decimal number

More information

University of Toronto. CSC340S - Information Systems Analysis and Design

University of Toronto. CSC340S - Information Systems Analysis and Design csc340 Information Systems Analysis and Design page 1/12 University of Toronto Faculty of Arts and Science Department of Computer Science CSC340S - Information Systems Analysis and Design Spring 2002 John

More information

TABLE OF CONTENTS 2 CHAPTER 1 3 CHAPTER 2 4 CHAPTER 3. Algorithm Design & Problem Solving. Programming. Databases

TABLE OF CONTENTS 2 CHAPTER 1 3 CHAPTER 2 4 CHAPTER 3. Algorithm Design & Problem Solving. Programming. Databases 2 CHAPTER 1 Algorithm Design & Problem Solving 3 CHAPTER 2 Programming 4 CHAPTER 3 Databases TABLE OF CONTENTS 1. ALGORITHM DESIGN & PROBLEM-SOLVING 1.1 Problem-solving & Design Every computer system is

More information

Conditional Execution

Conditional Execution Unit 3, Part 3 Conditional Execution Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Simple Conditional Execution in Java if () { else {

More information

DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6)

DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6) Technology & Information Management Instructor: Michael Kremer, Ph.D. Database Program: Microsoft Access Series DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6) AGENDA 3. Executing VBA

More information

LECTURE 5 Control Structures Part 2

LECTURE 5 Control Structures Part 2 LECTURE 5 Control Structures Part 2 REPETITION STATEMENTS Repetition statements are called loops, and are used to repeat the same code multiple times in succession. The number of repetitions is based on

More information

Algorithms, Part 2 of 3. Problem Solving. Problem Solving (con t) Topics Problem Solving Examples Pseudocode Control Structures

Algorithms, Part 2 of 3. Problem Solving. Problem Solving (con t) Topics Problem Solving Examples Pseudocode Control Structures Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode Control Structures Reading Section 3.3-3.10 (don t worry about understanding the C code, just the pseudocode) Problem Solving Decode this

More information

Programming. Why is programming fun?

Programming. Why is programming fun? Why is programming fun? Programming First is the sheer joy of making things. As the child delights in his mud pie, so the adult enjoys building things, especially things of his own design. I think this

More information

NOTES TO CONSIDER BEFORE ATTEMPTING EX 1A TYPES OF DATA

NOTES TO CONSIDER BEFORE ATTEMPTING EX 1A TYPES OF DATA NOTES TO CONSIDER BEFORE ATTEMPTING EX 1A TYPES OF DATA Statistics is concerned with scientific methods of collecting, recording, organising, summarising, presenting and analysing data from which future

More information

Chapter Two: Program Design Process and Logic

Chapter Two: Program Design Process and Logic Chapter Two: Program Design Process and Logic 2.1 Chapter objectives Describe the steps involved in the programming process Understand how to use flowchart symbols and pseudocode statements Use a sentinel,

More information

Instructional Technology & Technology Enhancement Center -itec Grade Center Tutorial for Faculty

Instructional Technology & Technology Enhancement Center -itec Grade Center Tutorial for Faculty Instructional Technology & Technology Enhancement Center -itec Grade Center Tutorial for Faculty Grade Center: Several changes have been made in new Grade Center including new icons. Note that grade center

More information

Course Outline. Introduction to java

Course Outline. Introduction to java Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.

More information

1 Information system An information system is the combination of technology(computers) and people that enable an organization to collect data, store them, and transform them into information Data Data

More information

Final Examination Semester 2 / Year 2010

Final Examination Semester 2 / Year 2010 Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2010 COURSE : PROGRAMMING LOGIC AND DESIGN COURSE CODE : CCIS1003 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM

More information

Chapter 5 Conditional and Iterative Statements. Statement are the instructions given to the computer to perform any kind of action.

Chapter 5 Conditional and Iterative Statements. Statement are the instructions given to the computer to perform any kind of action. Chapter 5 Conditional and Iterative Statements Statement Statement are the instructions given to the computer to perform any kind of action. Types of Statement 1. Empty Statement The which does nothing.

More information

Mathematical Computing

Mathematical Computing Mathematical Computing IMT2b2β Department of Mathematics University of Ruhuna A.W.L. Pubudu Thilan Department of Mathematics University of Ruhuna Mathematical Computing 1/47 Programming in Maxima Department

More information

CMPT 120 Introduction To Computing Science And Programming I. Pseudocode. Summer 2012 Instructor: Hassan Khosravi

CMPT 120 Introduction To Computing Science And Programming I. Pseudocode. Summer 2012 Instructor: Hassan Khosravi CMPT 120 Introduction To Computing Science And Programming I Pseudocode Summer 2012 Instructor: Hassan Khosravi Guessing game 1. Tell the user to pick a secret number between 1 and 100. 2. The smallest

More information

IT 1033: Fundamentals of Programming Loops

IT 1033: Fundamentals of Programming Loops IT 1033: Fundamentals of Programming Loops Budditha Hettige Department of Computer Science Repetitions: Loops A loop is a sequence of instruction s that is continually repeated until a certain condition

More information

CS162 Computer Science I Winter 2006 Practice Exam 2

CS162 Computer Science I Winter 2006 Practice Exam 2 Name: CS162 Computer Science I Winter 2006 Practice Exam 2 The real test will look much like this one, except, each part will have at most 4 problems. Please set aside 1 hour and take this test under real

More information

Chapter 2 - Control Structures

Chapter 2 - Control Structures Chapter 2 - Control Structures 1 Outline 2.1 Introduction 2.2 Algorithms 2.3 Pseudocode 2.4 Control Structures 2.5 if Selection Structure 2.6 if/else Selection Structure 2.7 while Repetition Structure

More information

CS110D: PROGRAMMING LANGUAGE I

CS110D: PROGRAMMING LANGUAGE I CS110D: PROGRAMMING LANGUAGE I Computer Science department Lecture 5&6: Loops Lecture Contents Why loops?? While loops for loops do while loops Nested control structures Motivation Suppose that you need

More information

LAB 5: SELECTION STATEMENTS

LAB 5: SELECTION STATEMENTS Statement Purpose: The purpose of this lab is to familiarize students with Conditional statements and explain how to control the sequence of statement execution, depending on the value of an expression

More information

SNS COLLEGE OF ENGINEERING,

SNS COLLEGE OF ENGINEERING, SNS COLLEGE OF ENGINEERING, COIMBATORE Department of Computer Science and Engineering QUESTION BANK(PART A) GE8151 - PROBLEM SOLVING AND PYTHON PROGRAMMING TWO MARKS UNIT-I 1. What is computer? Computers

More information

Crude Video Game Simulator Algorithm

Crude Video Game Simulator Algorithm Crude Video Game Simulator Algorithm The following program will simulate free games at an arcade. The player will enter his/her score for 5 levels of play. The sum of these is their game score. If this

More information

CMSC 201 Fall 2018 Lab 04 While Loops

CMSC 201 Fall 2018 Lab 04 While Loops CMSC 201 Fall 2018 Lab 04 While Loops Assignment: Lab 04 While Loops Due Date: During discussion, September 24 th through September 27 th Value: 10 points (8 points during lab, 2 points for Pre Lab quiz)

More information

Programming Language. Control Structures: Repetition (while) Eng. Anis Nazer Second Semester

Programming Language. Control Structures: Repetition (while) Eng. Anis Nazer Second Semester Programming Language Control Structures: Repetition (while) Eng. Anis Nazer Second Semester 2017-2018 Repetition statements Control statements change the order which statements are executed Selection :

More information

APPM 2460: Week Three For, While and If s

APPM 2460: Week Three For, While and If s APPM 2460: Week Three For, While and If s 1 Introduction Today we will learn a little more about programming. This time we will learn how to use for loops, while loops and if statements. 2 The For Loop

More information

LESSON 3 CONTROL STRUCTURES

LESSON 3 CONTROL STRUCTURES LESSON CONTROL STRUCTURES PROF. JOHN P. BAUGH PROFJPBAUGH@GMAIL.COM PROFJPBAUGH.COM CONTENTS INTRODUCTION... Assumptions.... Logic, Logical Operators, AND Relational Operators..... - Logical AND (&&) Truth

More information

1. Introduction to Programming

1. Introduction to Programming Computer Science I CS 135 1. Introduction to Programming René Doursat Department of Computer Science & Engineering University of Nevada, Reno Fall 2005 Computer Science I CS 135 0. Course Presentation

More information

Assignment: 1. (Unit-1 Flowchart and Algorithm)

Assignment: 1. (Unit-1 Flowchart and Algorithm) Assignment: 1 (Unit-1 Flowchart and Algorithm) 1. Explain: Flowchart with its symbols. 2. Explain: Types of flowchart with example. 3. Explain: Algorithm with example. 4. Draw a flowchart to find the area

More information

Chapter 4 The If Then Statement

Chapter 4 The If Then Statement The If Then Statement Conditional control structure, also called a decision structure Executes a set of statements when a condition is true The condition is a Boolean expression For example, the statement

More information

COMP322 - Introduction to C++ Lecture 01 - Introduction

COMP322 - Introduction to C++ Lecture 01 - Introduction COMP322 - Introduction to C++ Lecture 01 - Introduction Robert D. Vincent School of Computer Science 6 January 2010 What this course is Crash course in C++ Only 14 lectures Single-credit course What this

More information

Introduction to Conditionals

Introduction to Conditionals Introduction to Conditionals Conditional Statements Conditional statements are a key to programming and give us control over basic direction following and reasoning that the computer does. Conditional

More information

PROGRAM DESIGN TOOLS. Algorithms, Flow Charts, Pseudo codes and Decision Tables. Designed by Parul Khurana, LIECA.

PROGRAM DESIGN TOOLS. Algorithms, Flow Charts, Pseudo codes and Decision Tables. Designed by Parul Khurana, LIECA. PROGRAM DESIGN TOOLS Algorithms, Flow Charts, Pseudo codes and Decision Tables Pseudo-Code Pseudo-code is another programming tool that is used for planning the program. The word pseudo means imitation

More information

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-3 Flow Of Control Flow of control refers to the

More information

Variable A variable is a value that can change during the execution of a program.

Variable A variable is a value that can change during the execution of a program. Declare and use variables and constants Variable A variable is a value that can change during the execution of a program. Constant A constant is a value that is set when the program initializes and does

More information

BB4W. KS3 Programming Workbook INTRODUCTION TO. BBC BASIC for Windows. Name: Class:

BB4W. KS3 Programming Workbook INTRODUCTION TO. BBC BASIC for Windows. Name: Class: KS3 Programming Workbook INTRODUCTION TO BB4W BBC BASIC for Windows Name: Class: Resource created by Lin White www.coinlea.co.uk This resource may be photocopied for educational purposes Introducing BBC

More information

Algebra I Notes Linear Equations and Inequalities in Two Variables Unit 04c

Algebra I Notes Linear Equations and Inequalities in Two Variables Unit 04c Big Idea: Describe the similarities and differences between equations and inequalities including solutions and graphs. Skill: graph linear equations and find possible solutions to those equations using

More information

Student. Portal. User. Manual

Student. Portal. User. Manual EDUCATIONAL SERVICES Student Portal User Manual Version 3.0 GENESIS STUDENT INFORMATION SYSTEM STUDENT PORTAL Introduction 3 Logging In & Logging Out 4 Student Summary Dashboard The Dashboard Attendance

More information

Chapter 3 Problem Solving and the Computer

Chapter 3 Problem Solving and the Computer Chapter 3 Problem Solving and the Computer An algorithm is a step-by-step operations that the CPU must execute in order to solve a problem, or to perform that task. A program is the specification of an

More information

Example. CS 201 Selection Structures (2) and Repetition. Nested if Statements with More Than One Variable

Example. CS 201 Selection Structures (2) and Repetition. Nested if Statements with More Than One Variable CS 201 Selection Structures (2) and Repetition Debzani Deb Multiple-Alternative Decision Form of Nested if Nested if statements can become quite complex. If there are more than three alternatives and indentation

More information

Lab 6B Coin Collection

Lab 6B Coin Collection HNHS Computer Programming I / IPFW CS 11400 Bower - Page 1 Lab 6B Coin Collection You will create a program that allows users to enter the quantities of an assortment of coins (quarters, dimes, nickels,

More information

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture 18 Switch Statement (Contd.) And Introduction to

More information

Chapter 1: Why Program? Main Hardware Component Categories 8/23/2014. Main Hardware Component Categories: Why Program?

Chapter 1: Why Program? Main Hardware Component Categories 8/23/2014. Main Hardware Component Categories: Why Program? Chapter 1: Introduction to Computers and Programming 1.1 Why Program? Why Program? Computer programmable machine designed to follow instructions Program instructions in computer memory to make it do something

More information

CMPT 100 : INTRODUCTION TO

CMPT 100 : INTRODUCTION TO CMPT 100 : INTRODUCTION TO COMPUTING TUTORIAL #5 : JAVASCRIPT 2 GUESSING GAME 1 By Wendy Sharpe BEFORE WE GET STARTED... If you have not been to the first tutorial introduction JavaScript then you must

More information

INDIVIDUAL RESERVATIONS

INDIVIDUAL RESERVATIONS INDIVIDUAL RESERVATIONS You will learn: 1. How to create individual reservations 2. How to add meals, services and products to them 3. How to settle reservations 4. How to issue fiscal documents 1. How

More information

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017 Control Structures Lecture 4 COP 3014 Fall 2017 September 18, 2017 Control Flow Control flow refers to the specification of the order in which the individual statements, instructions or function calls

More information

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department Program Development Cycle Program development

More information

MathBase5 Operating Instructions

MathBase5 Operating Instructions MathBase5 Operating Instructions Introduction MathBase5 is a collection of six programs that deal with shape and space. 1. Matching Shapes 2. Move a Square 3. Centimetre Squares 4. Rectangles and Squares

More information

What is Iteration? CMPT-101. Recursion. Understanding Recursion. The Function Header and Documentation. Recursively Adding Numbers

What is Iteration? CMPT-101. Recursion. Understanding Recursion. The Function Header and Documentation. Recursively Adding Numbers What is Iteration? CMPT-101 Week 6 Iteration, Iteration, Iteration, Iteration, Iteration, Iteration,... To iterate means to do the same thing again and again and again and again... There are two primary

More information

CSE115 Introduction to Computer Science I Coding Exercise #7 Retrospective Fall 2017

CSE115 Introduction to Computer Science I Coding Exercise #7 Retrospective Fall 2017 This week the main activity was a quiz activity, with a structure similar to our Friday lecture activities. The retrospective for the quiz is in Quiz-07- retrospective.pdf This retrospective explores the

More information

1. Description of RBbasic2K4 Lite Program

1. Description of RBbasic2K4 Lite Program 1. Description of RBbasic2K4 Lite Program In this paragraph, let's study the commands using at RBbasic2k4. It is based on the previous BASIC commands. You should know each command's function and use method

More information

Tutors Guide to the Platform

Tutors Guide to the Platform Tutors Guide to the Platform Log on to the platform with your codes. This will give you access to the course contents, the internal mail system and the administration side of the courses. This is the page

More information

AN INTRODUCTION TO SCRATCH (2) PROGRAMMING

AN INTRODUCTION TO SCRATCH (2) PROGRAMMING AN INTRODUCTION TO SCRATCH (2) PROGRAMMING Document Version 2 (04/10/2014) INTRODUCTION SCRATCH is a visual programming environment and language. It was launched by the MIT Media Lab in 2007 in an effort

More information

Parent. Portal. User. Manual

Parent. Portal. User. Manual EDUCATIONAL SERVICES Parent Portal User Manual Version 3.0 GENESIS STUDENT INFORMATION SYSTEM PARENT PORTAL Introduction 3 Logging In & Logging Out 4 Student Summary Dashboard The Dashboard Selecting a

More information

CS 2113 Midterm Exam, November 6, 2007

CS 2113 Midterm Exam, November 6, 2007 CS 2113 Midterm Exam, November 6, 2007 Problem 1 [20 pts] When the following VBA program is executed, what will be displayed in the message box? Option Explicit Sub problem1() Dim m As Integer, n As Integer

More information

Sign in to Create a new account or use an existing one (e.g. from your English class)

Sign in to  Create a new account or use an existing one (e.g. from your English class) Turnitin: Thesis Upload Students Manual General Information The plagiarism check is a mandatory part of your final examination and needs to be done before handing in the thesis. The check generates a report

More information

Visual Basic Course Pack

Visual Basic Course Pack Santa Monica College Computer Science 3 Visual Basic Course Pack Introduction VB.NET, short for Visual Basic.NET is a language that was first introduced by Microsoft in 1987. It has gone through many changes

More information

Grade 6 Math Circles Winter February 3/4 Sets. Some of These Things Are Not Like the Others

Grade 6 Math Circles Winter February 3/4 Sets. Some of These Things Are Not Like the Others Faculty of Mathematics Waterloo, Ontario N2L 3G1 Centre for Education in Mathematics and Computing Grade 6 Math Circles Winter 2015 - February 3/4 Sets Some of These Things Are Not Like the Others When

More information

CMSC201 Computer Science I for Majors

CMSC201 Computer Science I for Majors CMSC201 Computer Science I for Majors Lecture 05 Algorithmic Thinking Last Class We Covered Decision structures One-way (using if) Two-way (using if and else) Multi-way (using if, elif, and else) Nested

More information

CONDITION CONTROLLED LOOPS. Introduction to Programming - Python

CONDITION CONTROLLED LOOPS. Introduction to Programming - Python CONDITION CONTROLLED LOOPS Introduction to Programming - Python Generating Random Numbers Generating a random integer Sometimes you need your program to generate information that isn t available when you

More information

Outline. Program development cycle. Algorithms development and representation. Examples.

Outline. Program development cycle. Algorithms development and representation. Examples. Outline Program development cycle. Algorithms development and representation. Examples. 1 Program Development Cycle Program development cycle steps: Problem definition. Problem analysis (understanding).

More information

Flow Control: Branches and loops

Flow Control: Branches and loops Flow Control: Branches and loops In this context flow control refers to controlling the flow of the execution of your program that is, which instructions will get carried out and in what order. In the

More information

Try typing the following in the Python shell and press return after each calculation. Write the answer the program displays next to the sums below.

Try typing the following in the Python shell and press return after each calculation. Write the answer the program displays next to the sums below. Name: Date: Instructions: PYTHON - INTRODUCTORY TASKS Open Idle (the program we will be using to write our Python codes). We can use the following code in Python to work out numeracy calculations. Try

More information

Comp 151. Control structures.

Comp 151. Control structures. Comp 151 Control structures. admin quiz this week believe it or not only 2 weeks from exam. one a week each week after that. idle debugger Debugger: program that will let you look at the program as it

More information

How Do Robots Find Their Way?

How Do Robots Find Their Way? How Do Robots Find Their Way? Conditionals and Repetition http://en.wikipedia.org/wiki/file:cyclope_robot.jpg http://www.youtube.com/watch?v=_l9rklaskwu Learning Objectives Learn basic programming concepts

More information

Chapter Overview. More Flow of Control. Flow Of Control. Using Boolean Expressions. Using Boolean Expressions. Evaluating Boolean Expressions

Chapter Overview. More Flow of Control. Flow Of Control. Using Boolean Expressions. Using Boolean Expressions. Evaluating Boolean Expressions Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Copyright 2011 Pearson Addison-Wesley. All rights reserved.

More information

How Do I Choose Which Type of Graph to Use?

How Do I Choose Which Type of Graph to Use? How Do I Choose Which Type of Graph to Use? When to Use...... a Line graph. Line graphs are used to track changes over short and long periods of time. When smaller changes exist, line graphs are better

More information

6-3 Additional Data and Outliers

6-3 Additional Data and Outliers Warm Up Use the numbers to answer the questions. 146, 161, 114, 178, 150, 134, 172, 131, 128 1. What is the greatest number? 178 2. What is the least number? 114 3. How can you find the median? Order the

More information

The action of the program depends on the input We can create this program using an if statement

The action of the program depends on the input We can create this program using an if statement The program asks the user to enter a number If the user enters a number greater than zero, the program displays a message: You entered a number greater than zero Otherwise, the program does nothing The

More information

Programming Basics and Practice GEDB029 Decision Making, Branching and Looping. Prof. Dr. Mannan Saeed Muhammad bit.ly/gedb029

Programming Basics and Practice GEDB029 Decision Making, Branching and Looping. Prof. Dr. Mannan Saeed Muhammad bit.ly/gedb029 Programming Basics and Practice GEDB029 Decision Making, Branching and Looping Prof. Dr. Mannan Saeed Muhammad bit.ly/gedb029 Decision Making and Branching C language possesses such decision-making capabilities

More information