FOR LOOP STRUCTURE For := to do eg. for I := 1 to 100 do begin writeln(‘This is a loop’); end;

Slides:



Advertisements
Similar presentations
Chapter 4 Ch 1 – Introduction to Computers and Java Flow of Control Loops 1.
Advertisements

E.g.9 For to do loop for i:=1 to 10 do writeln(i); While do loop i:=1;
Selection Process If … then … else.... Condition Process 2 Process 1 Y.
Looping while … do …. Condition Process 2 Process 1 Y Repeated Loop.
1 Arrays in JavaScript Name of array (Note that all elements of this array have the same name, c ) Position number of the element within array c c[6] c[0]
Program CheckPass; var TestScore, ExamScore : integer; FinalScore : real; Status : string; begin write(‘Enter the Test score:’); readln(Testscore); write(‘Enter.
James Tam Arrays In this section of notes you will be introduced to a homogeneous composite type, one- dimensional arrays.
James TamThe Bubble Sort in Pascal Sorting (Bubble) In this section of notes you will learn one technique for ordering a list.
James Tam Getting Started With Pascal Programming How are computer programs created What is the basic structure of a Pascal Program Variables in Pascal.
James Tam Arrays In this section of notes you will be introduced to a homogeneous composite type, one- dimensional arrays.
James Tam Arrays In this section of notes you will be introduced to a homogeneous composite type, one- dimensional arrays.
James Tam Sorting (Bubble) In this section of notes you will learn one technique for ordering a list.
James Tam Sorting (Bubble) In this section of notes you will learn one technique for ordering a list.
J. Michael Moore Other Control Structures CSCE 110 Influenced by material developed by James Tam & Jennifer Welch.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 3, Lecture 2.
James Tam program investors (input, output, investorList, updatedInvestorList); const MAXCLIENTS = 10; NAMELENGTH = 30; LENGTH = 30; type Client =
1 10/20/08CS150 Introduction to Computer Science 1 do/while and Nested Loops Section 5.5 & 5.11.
James Tam Getting Started With Pascal Programming What is the basic structure of a Pascal Program Variables in Pascal Performing input and output with.
James Tam Arrays In this section of notes you will be introduced to a homogeneous composite type, one- dimensional arrays.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 2, Lecture 2.
J. Michael Moore Input and Output (IO) CSCE 110 Drawn from James Tam's material.
J. Michael Moore Other Control Structures CSCE 110 Influenced by material developed by James Tam & Jennifer Welch.
James Tam Loops In Pascal In this section of notes you will learn how to rerun parts of your program without having to duplicate the code.
J. Michael Moore Modules – the Basics CSCE 110 Influenced by material developed by James Tam & Jennifer Welch.
Input and Output (IO) CSCE 110 Drawn from James Tam's material.
CMP 131 Introduction to Computer Programming
J. Michael Moore Modules – the Basics CSCE 110 Influenced by material developed by James Tam & Jennifer Welch.
Last Week Doctests Lists List methods Nested Lists Aliasing.
110-K1 Iterations (1) Up to now, need to call the procedure again (e.g. click again on a command button) To repeat a piece of code: Can also use loops:
ARRAY PADA PASCAL DOSEN : NURAINI PURWANDARI.
ARRAYS 1.Basic Ideas 2.The Array Type 3.Processing Arrays 4.Parallel Arrays 5.Two-dimensional Array 6.Arrays as Parameters.
Lecture 26 Final review. Problem 1 (10 points) How many times would the FOR-DO loops beginning with the following statements be executed? If the loop.
Introduction to Pascal The Basics of Program writing.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 5, Lecture 1 (Monday)
Programming, an introduction to Pascal
Count and add list of numbers From user input and from file.
Role of variables. Fixed value Description: A variable without any calculation and not changed thereafter; for example we may need to remember the number.
Assignment statement and Arithmetic operation 1 The major part of data processing.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 10.
PASCAL PROGRAMMING.
1 do-while Statement 2 Do-While Statement Is a looping control structure in which the loop condition is tested after each iteration of the loop. SYNTAX.
1 Looping Dale/Weems/Headington. 2 KA/JS/P Warning l Save your work often! l In the Khan Academy, JavaScript environment, infinite loops will lock up.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 11.
Array : 1-dimension อนันต์ ผลเพิ่ม Anan Phonphoem
CMP 131 Introduction to Computer Programming
15.1 More About High-Level Programming Languages Syntax and Semantics Each programming language contains its own rules for both syntax and semantics. Syntax.
Chapter 2 – part b Brent M. Dingle Texas A&M University
RECORDS Introduction Declaring a record Using records
تهیه و تنظیم: فاطمه قاسمی دانشگاه صنعتی شریف – پاییز 86
While Loops (Iteration 2)
Көңіл күйлеріңіз қалай?
مراجعة الحاسب.
البرمجة بلغة الفيجول بيسك ستوديو
البرمجة بلغة فيجول بيسك ستوديو
Сызықтық алгоритмдерді бағдарламалау
Бірөлшемді жиымдар Паскаль тілінде бағдарламалау
kbkjlj/m/lkiubljj'pl;
Computer Science 1 Get out your notebook
Pascal Subprogram Procedure Function Build in Function (e.g. Sin(x))
Sorting (Bubble) In this section of notes you will learn one technique for ordering a list.
Қайталау операторлары
9 сынып 8 сабақ Сабақтың тақырыбы: Дейін циклі REPEAT операторы.
The structure of programming
Computer Science 1 For..do loop Dry Run Take notes on the For loop
Computer Science
½ of 6 = 3.
Types of loops definite loop: A loop that executes a known number of times. Examples: Repeat these statements 10 times. Repeat these statements k times.
Computer Science 1 Get out your notebook
Computer Science 1 Get out your notebook
BETONLINEBETONLINE A·+A·+
Presentation transcript:

FOR LOOP STRUCTURE For := to do eg. for I := 1 to 100 do begin writeln(‘This is a loop’); end;

For program example Program loops; var a: integer begin for a := 1 to 10 begin writeln(‘This is loop’, a); readln end; end.

While loop structure while do eg. read (num); while num <> 999 do begin sum := sum + num; writeln(‘the sum is’, sum); read(num); end;

WHILE PROGRAM EXAMPLE program squareroot; var square,num: integer begin read(num); while num <> 999 do begin square := num * num; writeln(‘ The square is’, square); read(num); end; end.

WHILE PROGRAM EXAMPLE program whileloop; var num: integer; begin while num < 25 do begin writeln(‘ this is loop number’ num); num := num +1 readln; end; end.

Repeat Until Loop Structure repeat until eg. repeat writeln(‘this is a loop again’); readln; a:=a +1 until a > 10

Repeat Until Loop Example program password; const password = 1234 var p: integer; begin repeat writeln(‘enter the password’); read(p); until p=password; end.