Programming Lecture #4 CS 101 Autumn 2006 Tariq Jadoon.

Slides:



Advertisements
Similar presentations
Switch code for Lab 4.2 switch (input) { /* input is a variable that we will test. */ case 'M': printf("The prefix is equal to 1E6.\n"); break; case 'k':
Advertisements

Repetition Statements Perform the same task repeatedly Allow the computer to do the tedious, boring things.
Introduction to Assembly language
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
Static Single Assignment CS 540. Spring Efficient Representations for Reachability Efficiency is measured in terms of the size of the representation.
CS0004: Introduction to Programming Repetition – Do Loops.
Iteration (Looping Constructs in VB) Iteration: Groups of statements which are repeatedly executed until a certain test is satisfied Carrying out Iteration.
Example – calculating interest until the amount doubles using a for loop: will calculate up to 1000 years, if necessary if condition decides when to terminate.
Lesson 4: Basic Algorithm Tools If, While Do For Loop, Else, Switch Case.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Programming Lecture #3 CS 101 Autumn 2006 Tariq Jadoon.
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
Programming Lecture #2 CS 101 Autumn 2007 Tariq Jadoon.
Guidelines for working with Microsoft Visual Studio.Net.
Guidelines for working with Microsoft Visual Studio 6.
Week 7 - Programming II Today – more features: – Loop control – Extending if/else – Nesting of loops Debugging tools Textbook chapter 7, pages
Decisions, Loops, and Arrays Achmad Arwan, S.Kom.
Lecture 8: Choosing the Correct Loop. do … while Repetition Statement Similar to the while statement Condition for repetition only tested after the body.
Copyright © 2001 by Wiley. All rights reserved. Chapter 5: The Repetition Process in Visual Basic Event Driven Loops Determinate Loops Indeterminate Loops.
CONTROLLING PROGRAM FLOW
VB – Debugging Tools Appendix D. Why do we need debugging? Every program has errors, and the process of finding these errors is debugging Types of errors.
New Tools And Workshop Mod & For Loops. Modulo Calculates the remainder (remember long division?) % Examples: 7 % 3 10 % 2 2 % 3 evaluates to 1 evaluates.
1 09/20/04CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
Chapter 6 Looping CS185/09 - Introduction to Programming Caldwell College.
1 Conditionals In many cases we want our program to make a decision about whether a piece of code should be executed or not, based on the truth of a condition.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #5: Programming Structures IE 212: Computational Methods for Industrial Engineering.
Web Development in Microsoft Visual Studio Slide 2 Lecture Overview How to create a first ASP.NET application.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 5: Introduction to C: More Control Flow.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 ‏ Control Structures.
Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables.
Debuggers in Python. The Debugger Every programming IDE has a tool called a debugger. This application does NOT locate or fix your bugs for you! It slows.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Often being different. Control flow By default Java (and therefore Processing) executes lines of a program one after the other –Doesn’t matter what happened.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
NETBEANS DEBUGGER.  To create a breakpoint place the cursor at the desired location.  Go to the Run -> toogle line Breakpoint or Ctrl +F8. It creates.
Repetition 8/9/2009. Learning to Program -- Suggestions Spend a lot of time fiddling around with code –Programming is something you have to learn by doing.
Introduction to Programming Lecture 2 Msury Mahunnah, Department of Informatics, Tallinn University of Technology.
Working with Loops, Conditional Statements, and Arrays.
Input Boxes, List Boxes, and Loops Chapter 5. 2 Input Boxes Method for getting user’s attention to obtain input. InputBox() for obtaining input MessageBox()
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.
1 CSC103: Introduction to Computer and Programming Lecture No 9.
1 Looping Chapter 6 2 Getting Looped in C++ Using flags to control a while statement Trapping for valid input Ending a loop with End Of File condition.
Chapter 5: Looping. Using the while Loop Loop – A structure that allows repeated execution of a block of statements Loop body – A block of statements.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
The Repetition control structure using while loop.
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.
PHP Condtions and Loops Prepared by Dr. Maher Abuhamdeh.
Introduction to Programming
Introduction to Programming Lecture 2
CHAPTER 4 DECISIONS & LOOPS
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Loops in Java.
Control Structures.
Computer Programming I
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2B) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
Ch 7: JavaScript Control Statements I.
ITM 352 Flow-Control: Loops
Debugging Techniques.
Programming Fundamentals Lecture #6 Program Control
IF if (condition) { Process… }
CSC115 Introduction to Computer Programming
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
Lab5 PROGRAMMING 1 Loop chapter4.
Case & Repetitive Statements
Debugging Visual Basic Programs
Loop Construct.
PROGRAM FLOWCHART Iteration Statements.
Python While Loops.
G6DICP - Lecture 5 Control Structures.
Presentation transcript:

Programming Lecture #4 CS 101 Autumn 2006 Tariq Jadoon

In Lecture #3 Swapping Variables Conditional Code

Swapping the Contents of Two Variables X = 10 Y = 20 Temp = Y Y = X X Y Temp 20 10

Swapping the Contents of Two Variables X = 10 Y = 20 Temp = Y Y = X X = Temp X Y 10 Temp 20

Debugging Using the Immediate Window as a scratchpad Placing Breakpoints Single stepping (F8) Placing Watches

Conditional Code VB has a number of block structures for conditional code: IF condition THEN action IF condition THEN action1 action2... END IF

Conditional Code (contd.) IF condition THEN action1 … ELSE action2 … END IF

Today Conditional Code (contd.) Loops

Conditional Code (contd.) IF condition1 THEN action1 … ElseIf condition2 THEN action2 … ElseIf condition3 THEN action3 … Else default action … END IF

Loops Repeat code –Counter Initial value Terminal Value Increment (step size)

Loops For c = 1 to 10 Step 2 action1 action2 … Next c Initial Value Terminal Value Increment Value Body of the loop Increment and check terminating condition