Computer Science II TURBO PASCAL

Size: px
Start display at page:

Download "Computer Science II TURBO PASCAL"

Transcription

1 Computer Science II TURBO PASCAL WEEK4 Program Flow Commands Dr.ELGİN KILIÇ

2 IF THEN ELSE expression: If <case> then Begin <Processes when CASE is TRUE> End else Begin < Processes when CASE is FALSE> End;

3 Example: For given 100 integers by keyboard control whether number is negative positive or zero. Label A1; Var a,t: integer; begin T:=0; A1: write( Enter a number please. ); readln(a); t:=t+1; if (a>0) then writeln( The given number is positive. ); else if (a<>0) then writeln( The given number is negative. ); If (t<100) then goto A1; readln; {Let us to see the output on screen} end.

4 Example: For any person weight and height values are given. And ideal weight is calculated as follows; For Women and For men ideal weight=height-108 ideal weight=height-110, Write a pascal program to show the output below; ideal weight> weight You should gain weight. ideal weight< weight You should loose weight. ideal weight = weight You are on ideal weight.

5 Label bas; Var SAY,w,h,ideal:byte; gender,answer:char; Begin SAY:=0; bas: SAY:=SAY+1; Writeln( Enter gender ); readln(gender); writeln( Weight= ); readln(w); writeln( Height= ); readln(h); if (gender= F ) or (gender= f ) then ideal:=h-110 else ideal:=h-108 if ideal>w then writeln ( You should gain, ideal-w) else if ideal<w then writeln ( loose, w-ideal ) else writeln( You are at ideal weight. ); {SAY:=SAY+1;} If (SAY<50) THEN GOTO BAS; Readln;

6 Example: In a laboratory there are 50 researchers. Each researcher does an experiment 5 times per day for 30 days. Write a Pascal Program to find; a) Daily Average of each researcher b) Monthly average of each researcher c) Maximum of daily averages of researchers and the day in which this maximum value is obtained.

7 Label 5,10,20; Var kisi,gun,ds,gun1: byte; ort,top1,enb: real; d,top: integer; Begin kisi:=0; 5: kisi:=kisi+1; gun:=0; top1:=0; 10: gun:=gun+1; ds:=0; top:=0; 20: ds:=ds+1; writeln( result of,ds, expr of,kisi, researcher in,gun, day = ); readln(d); top:=top+d;

8 if ds<5 then goto 20; ort:=top/5; writeln( Average=, ort); if gun=1 then begin enb:=ort; gun1:=gun; end else if enb<ort then begin enb:=ort; gun1:=gun; end; top1:=top1+ort; if gun<30 then goto 10; writeln( Answer of b =,enb,gun1); writeln( Answer of a =, top1/30); if kisi<50 then goto 5; end.

9 EXAMPLE: b n 1 x 2n 1 (2n 1)! Write a Pascal program to find the result of formula above for given only one x, b pair.

10 Label 5,10,20; Var x,b,n,i,k: integer; car,carp1: longint; t,top: real; Begin writeln( Enter x b values ); readln(x,b); n:=0; top:=0.0; 5: n:=n+1;

11 i:=0; carp:=1; 20: i:=i+1; carp:=carp*x; if (i<2*n-1) then goto 20; {power process} k:=0; carp1:=1; 10: k:=k+1; carp1:=carp1*k; if (k<2*n-1) then goto10; {factorial process} end. t:=carp/carp1; top:=top+t; if n<b then goto 5; writeln( sonuç=, top);

12 Homework: For given 100 a, b, c a b, M=a+b+3c a > b, M=5a+2b+4c Write a Pascal program to find triples M is calculated as follows; a) How many M values are divisible by 4 when a>b? b) What is the minimum M value when a<b and a, b, c triple giving this minimum value? c) First calculated M value when a=b. Z

13 CASE ----OF This structure is used to change the flow of program depending on many cases of one variable (input data). Type of input can be numeric or character based. Program process the part when the constant value is equal to given input. If no case is satisfied then ELSE part runs. It is not compulsory to use else part.

14 Case EXPRESSION OF const value1: Process / Begin Processes End; const value2: Process / Begin Processes End;... const value n: Process / Begin Processes End; [ELSE Process/ Processes] End;

15 Example: In a shop there 5 types of products are sold. This sale process stops when product type is given as a negative input. Write a Pascal Program to find HOW MANY OF EACH TYPE OF PRODUCT is sold when sales process stopped.

16 Label A1; Var t1,t2,t3,t4,t5,type:integer; Begin t1:=0;t2:=0;t3:=0;t4:=0;t5:=0; A1: Writeln( Enter product type as 1/2/3/4/5. ); Readln(type); If (type=1) then t1:=t1+1; If (type=2) then t2:=t2+1; If (type=3) then t3:=t3+1; If (type=4) then t4:=t4+1; If (type=5) then t5:=t5+1; end; If (type>0) then goto a1; Writeln( Total amounts= ); Writeln(t1,t2,t3,t4,t5); readln; end.

17 Label A1; Var t1,t2,t3,t4,t5,type:integer; Begin t1:=0;t2:=0;t3:=0;t4:=0;t5:=0; A1: Writeln( Enter product type as 1/2/3/4/5. ); Readln(type); Case type of 1: t1:=t1+1; 2: t2:=t2+1; 3: t3:=t3+1; 4: t4:=t4+1; 5: t5:=t5+1; end; If (type>0) then goto a1; Writeln( Total amounts= ); Writeln( type1=,t1,t2,t3,t4,t5); readln; end.

18 Example: In a shop there 5 types of products are sold. This sale process stops when product type is given as Z. Write a Pascal Program to find HOW MANY OF EACH TYPE OF PRODUCT is sold when sales process stopped.

19 Label A1; Var t1,t2,t3,t4,t5:integer; type:char; Begin t1:=0;t2:=0;t3:=0;t4:=0;t5:=0; A1: Writeln( Enter product type as A/B/C/D/E. ); Readln(type); If (type= A ) then t1:=t1+1; If (type= B ) then t2:=t2+1; If (type= C ) then t3:=t3+1; If (type= D ) then t4:=t4+1; If (type= E ) then t5:=t5+1; If (type<> Z ) then goto a1; Writeln( Total amounts= ); Writeln(t1,t2,t3,t4,t5); readln; end.

20 Label A1; Var t1,t2,t3,t4,t5 :integer; type:char; Begin t1:=0;t2:=0;t3:=0;t4:=0;t5:=0; A1: Writeln( Enter product type as A/B/C/D/E. ); Readln(type); Case type of A : t1:=t1+1; B : t2:=t2+1; C : t3:=t3+1; D : t4:=t4+1; E : t5:=t5+1; end; If (type<> Z ) then goto a1; Writeln( Total amounts= ); Writeln( pro1=,t1, pro2=,t2, prod3=,t3, p4=,t4, P5=,t5); readln; end.

21 Example: Write a Pascal Program to find LETTER notation of a student s grade according to intervals below AA BA BB CC DD 0-45 FD

22 Var g:integer; Begin Writeln( Enter student s grade. ); Readln(g); Case g of :writeln( FD ); : writeln( DD ); : writeln( CC ); : writeln( BB ); : writeln( BA ); : writeln( AA ); end; Readln; END.

23 Label A1; Var i,g:integer; Begin i:=0; A1: Writeln( Enter student s grade. ); Readln(g); i:=i+1; {ANA SAYAÇ} Case g of :writeln( FD ); : writeln( DD ); : writeln( CC ); : writeln( BB ); : writeln( BA ); : writeln( AA ); end; If (i<100) then goto a1; Readln; END. If there have been 100 students in the class, then solution will be like shown in left side.

24 Example: Write a Pascal Program to find LETTER notation of a student s grade according to intervals below in a class of 100 students and how many students are there in each INTERVAL AA BA BB CC DD 0-45 FD

25 Label A1; Var i,x,y,z,t,w,v,g:integer; Begin i:=0;x:=0;y:=0;z:=0;t:=0;w:=0;v:=0; A1: Writeln( Enter student s grade. ); Readln(g); i:=i+1; Case g of :begin writeln( FD ); x:=x+1;end; : begin writeln( DD ); y:=y+1;end; : begin writeln( CC ); z:=z+1;end; : begin writeln( BB ); t:=t+1;end; : begin writeln( BA ); w:=w+1;end; : begin writeln( AA ); v:=v+1;end; end; If (i<100) then goto a1;

26 Writeln( There are,x, students in FD ); Writeln( There are,y, students in DD ); Writeln( There are,z, students in CC ); Writeln( There are,w, students in BB ); Writeln( There are,t, students in BA ); Writeln( There are,v, students in AA ); readln; end.

27 Example: The amount of products that an employee produced in one is given day by day. Employee earns 25TL per each item of product at the first half of the month and 15TL per item at the last 15 days of the month. Write a Pascal Program to find the total amount of products and earning of this employee at the end of the month.

28 Label bas; Var ps,gun,topu,topps,ucret:integer; Begin Gun:=0;topu:=0; topps:=0; bas: Writeln( Enter number (amount) of products ); Readln(ps); Gun:=gun+1; Case gun of :ucret:=ps*25; :ucret:=ps*15; end; topu:=topu+ucret; topps:=topps+ps; if gun<30 then goto bas; writeln (topu, topps); end.

COMPUTER SCIENCES II Spring Term 2017 Asst.Prof.Elgin KILIÇ

COMPUTER SCIENCES II Spring Term 2017 Asst.Prof.Elgin KILIÇ COMPUTER SCIENCES II Spring Term 2017 Asst.Prof.Elgin KILIÇ TURBO PASCAL WEEK 2 DECLARATION BLOCKS in DETAIL Uses There default sub pascal programs called UNITS which are already embedded in pascal editor.

More information

Computer Science II TURBO PASCAL

Computer Science II TURBO PASCAL Computer Science II TURBO PASCAL WEEK6 LOOP structures Dr.ELGİN KILIÇ Loop Type Description while-do loop Repeats a statement or group of statements while a given condition is true. It tests the condition

More information

CMSC 2833 Lecture Memory Organization and Addressing

CMSC 2833 Lecture Memory Organization and Addressing Computer memory consists of a linear array of addressable storage cells that are similar to registers. Memory can be byte-addressable, or word-addressable, where a word typically consists of two or more

More information

DSCI 325: Handout 6 More on Manipulating Data in SAS Spring 2017

DSCI 325: Handout 6 More on Manipulating Data in SAS Spring 2017 DSCI 325: Handout 6 More on Manipulating Data in SAS Spring 2017 CREATING VARIABLES IN SAS: A WRAP-UP As you have already seen several times, SAS variables can be created with an assignment statement in

More information

Section 9: Exponential and Logarithmic Functions

Section 9: Exponential and Logarithmic Functions Topic 1: Real-World Exponential Growth and Decay Part 1... 189 Topic 2: Real-World Exponential Growth and Decay Part 2... 191 Topic 3: Interpreting Exponential Equations... 192 Topic 4: Euler s Number...

More information

3. Can every Do-Loop loop be written as a For-Next loop? Why or why not? 4. Name two types of files that can be opened and used in a VB program.

3. Can every Do-Loop loop be written as a For-Next loop? Why or why not? 4. Name two types of files that can be opened and used in a VB program. CE 311 K Fall 005 Second Exam - Examples Answers at the bottom. 1. What are two categories of flow control structures?. Name three logical operators in Visual Basic (VB). 3. Can every Do-Loop loop be written

More information

Discrete Structures. Fall Homework3

Discrete Structures. Fall Homework3 Discrete Structures Fall 2015 Homework3 Chapter 5 1. Section 5.1 page 329 Problems: 3,5,7,9,11,15 3. Let P(n) be the statement that 1 2 + 2 2 + +n 2 = n(n + 1)(2n + 1)/6 for the positive integer n. a)

More information

CIS-331 Spring 2016 Exam 1 Name: Total of 109 Points Version 1

CIS-331 Spring 2016 Exam 1 Name: Total of 109 Points Version 1 Version 1 Instructions Write your name on the exam paper. Write your name and version number on the top of the yellow paper. Answer Question 1 on the exam paper. Answer Questions 2-4 on the yellow paper.

More information

Reviewing all Topics this term

Reviewing all Topics this term Today in CS161 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for) Functions (pass by value, pass by reference) Arrays (specifically arrays of characters)

More information

Homework Set 5 (Sections )

Homework Set 5 (Sections ) Homework Set 5 (Sections.4-.6) 1. Consider the initial value problem (IVP): = 8xx yy, yy(1) = 3 a. Do 10 steps of Euler s Method, using a step size of 0.1. Write the details in the table below. Work to

More information

History. used in early Mac development notable systems in Pascal Skype TeX embedded systems

History. used in early Mac development notable systems in Pascal Skype TeX embedded systems Overview The Pascal Programming Language (with material from tutorialspoint.com) Background & History Features Hello, world! General Syntax Variables/Data Types Operators Conditional Statements Functions

More information

Polynomial Functions I

Polynomial Functions I Name Student ID Number Group Name Group Members Polnomial Functions I 1. Sketch mm() =, nn() = 3, ss() =, and tt() = 5 on the set of aes below. Label each function on the graph. 15 5 3 1 1 3 5 15 Defn:

More information

(c) ((!(a && b)) == (!a!b)) TRUE / FALSE. (f) ((!(a b)) == (!a &&!b)) TRUE / FALSE. (g) (!(!a) && (c-d > 0) && (b!b))

(c) ((!(a && b)) == (!a!b)) TRUE / FALSE. (f) ((!(a b)) == (!a &&!b)) TRUE / FALSE. (g) (!(!a) && (c-d > 0) && (b!b)) ComS 207: Programming I Midterm 2, Tue. Mar 21, 2006 Student Name: Student ID Number: Recitation Section: 1. True/False Questions (10 x 1p each = 10p) Determine the value of each boolean expression given

More information

Getting Started With Pascal Programming

Getting Started With Pascal Programming Getting Started With Pascal Programming How are computer programs created What is the basic structure of a Pascal Program Variables and constants Input and output Pascal operators Common programming errors

More information

Computer Science III WEEK4 Dr.Elgin KILIÇ

Computer Science III WEEK4 Dr.Elgin KILIÇ Computer Science III 2018-2019 LOOPS FOR LOOP STATEMENT WEEK4 Dr.Elgin KILIÇ A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number

More information

ADD Identifier-1 TO Identifier-2 Literal-1. ADD Identifier-1. GIVING Identifier-2 Literal-1

ADD Identifier-1 TO Identifier-2 Literal-1. ADD Identifier-1. GIVING Identifier-2 Literal-1 The Basic Arithmetic Verbs All basic arithmetic operations of ADD, SUBTRACT, MULTIPLY, and DIVIDE require the fields operated on :- 1) Have numeric PICTURE clause 2) Actually have numeric data when the

More information

Annex A (Informative) Collected syntax The nonterminal symbols pointer-type, program, signed-number, simple-type, special-symbol, and structured-type

Annex A (Informative) Collected syntax The nonterminal symbols pointer-type, program, signed-number, simple-type, special-symbol, and structured-type Pascal ISO 7185:1990 This online copy of the unextended Pascal standard is provided only as an aid to standardization. In the case of dierences between this online version and the printed version, the

More information

Comparing and Modeling with Functions

Comparing and Modeling with Functions Name Date Class 13 Comparing and Modeling with Functions Quiz 1. Which of the following data sets is best described by a linear model? A {(5, 1), (4, 2), (3, 4), (2, 8)} B {(5, 1), (4, 1), (3, 3), (2,

More information

STAT 7000: Experimental Statistics I

STAT 7000: Experimental Statistics I STAT 7000: Experimental Statistics I 2. A Short SAS Tutorial Peng Zeng Department of Mathematics and Statistics Auburn University Fall 2009 Peng Zeng (Auburn University) STAT 7000 Lecture Notes Fall 2009

More information

Comp 333: Concepts of Programming Languages Fall 2016

Comp 333: Concepts of Programming Languages Fall 2016 Comp 333: Concepts of Programming Languages Fall 2016 Instructor: Professor Schwartz History Syntax and Semantics Compilers Language Constructs Names, Binding, Scoping, Data Types Expressions, Control

More information

The vertex set is a finite nonempty set. The edge set may be empty, but otherwise its elements are two-element subsets of the vertex set.

The vertex set is a finite nonempty set. The edge set may be empty, but otherwise its elements are two-element subsets of the vertex set. Math 3336 Section 10.2 Graph terminology and Special Types of Graphs Definition: A graph is an object consisting of two sets called its vertex set and its edge set. The vertex set is a finite nonempty

More information

GOZO COLLEGE. Boys Secondary Victoria - Gozo, Malta Ninu Cremona. Half Yearly Examination

GOZO COLLEGE. Boys Secondary Victoria - Gozo, Malta Ninu Cremona. Half Yearly Examination GOZO COLLEGE Boys Secondary Victoria - Gozo, Malta Ninu Cremona Half Yearly Examination 2010 2011 Subject: Form: Time: COMPUTER STUDIES 4 Junior Lyceum 1 hr 30 min NAME: CLASS: INDEX NO: Instructions to

More information

4. Specifications and Additional Information

4. Specifications and Additional Information 4. Specifications and Additional Information AGX52004-1.0 8B/10B Code This section provides information about the data and control codes for Arria GX devices. Code Notation The 8B/10B data and control

More information

CIS-331 Final Exam Spring 2015 Total of 115 Points. Version 1

CIS-331 Final Exam Spring 2015 Total of 115 Points. Version 1 Version 1 1. (25 Points) Given that a frame is formatted as follows: And given that a datagram is formatted as follows: And given that a TCP segment is formatted as follows: Assuming no options are present

More information

Math 96--Radicals #1-- Simplify; Combine--page 1

Math 96--Radicals #1-- Simplify; Combine--page 1 Simplify; Combine--page 1 Part A Number Systems a. Whole Numbers = {0, 1, 2, 3,...} b. Integers = whole numbers and their opposites = {..., 3, 2, 1, 0, 1, 2, 3,...} c. Rational Numbers = quotient of integers

More information

ACSL All-Star Practice, Woburn CI, (T AR) + S R = ART S + ST + AR

ACSL All-Star Practice, Woburn CI, (T AR) + S R = ART S + ST + AR ACSL All-Star Practice, Woburn CI, 2008 1 Question 1. Which is bigger: 0.11 10 or 0.000111 2? Question 2. How many boolean strings RAT S satisfy the following equation? (T AR) + S R = ART S + ST + AR Question

More information

CIS-331 Final Exam Spring 2018 Total of 120 Points. Version 1

CIS-331 Final Exam Spring 2018 Total of 120 Points. Version 1 Version 1 Instructions 1. Write your name and version number on the top of the yellow paper and the routing tables sheet. 2. Answer Question 2 on the routing tables sheet. 3. Answer Questions 1, 3, 4,

More information

Advanced Algebra I Simplifying Expressions

Advanced Algebra I Simplifying Expressions Page - 1 - Name: Advanced Algebra I Simplifying Expressions Objectives The students will be able to solve problems using order of operations. The students will identify expressions and write variable expressions.

More information

Syllabus of Diploma Engineering. Computer Engineering. Semester: II. Subject Name: Computer Programming. Subject Code: 09CE1104

Syllabus of Diploma Engineering. Computer Engineering. Semester: II. Subject Name: Computer Programming. Subject Code: 09CE1104 Semester: II Subject Name: Computer Programming Subject Code: 09CE1104 Objective: This Course will help to develop programming skills in the students, using a structured programming language `C'. Students

More information

CSCI 131, Midterm Exam 1 Review Questions This sheet is intended to help you prepare for the first exam in this course. The following topics have

CSCI 131, Midterm Exam 1 Review Questions This sheet is intended to help you prepare for the first exam in this course. The following topics have CSCI 131, Midterm Exam 1 Review Questions This sheet is intended to help you prepare for the first exam in this course. The following topics have been covered in the first 5 weeks of the course. The exam

More information

Section 7: Exponential Functions

Section 7: Exponential Functions Topic 1: Geometric Sequences... 175 Topic 2: Exponential Functions... 178 Topic 3: Graphs of Exponential Functions - Part 1... 182 Topic 4: Graphs of Exponential Functions - Part 2... 185 Topic 5: Growth

More information

Getting Started With Pascal Programming

Getting Started With Pascal Programming Getting Started With Pascal Programming How are computer programs created What is the basic structure of a Pascal Program Variables and constants Input and output Common programming errors Computer Programs

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

Class 2: Variables and Memory. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski)

Class 2: Variables and Memory. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski) Class 2: Variables and Memory Variables A variable is a value that is stored in memory It can be numeric or a character C++ needs to be told what type it is before it can store it in memory It also needs

More information

Assignment 3: Distance COP3330 Fall 2017

Assignment 3: Distance COP3330 Fall 2017 Assignment 3: Distance COP3330 Fall 2017 Due: Monday, October 16, 2017 at 11:59 PM Objective This assignment will provide experience with basic operator overloading. Task Your task will be to create a

More information

CSCE 531, Spring 2015 Final Exam Answer Key

CSCE 531, Spring 2015 Final Exam Answer Key CSCE 531, Spring 2015 Final Exam Answer Key 1. (40 points total) Consider the following grammar with start symbol S : S S S asb S T T T a T cs T ɛ (a) (10 points) Find FIRST(S), FIRST(T ), FOLLOW(S), and

More information

MODULE 2: Branching and Looping

MODULE 2: Branching and Looping MODULE 2: Branching and Looping I. Statements in C are of following types: 1. Simple statements: Statements that ends with semicolon 2. Compound statements: are also called as block. Statements written

More information

Hrs Hrs Hrs Hrs Hrs Marks Marks Marks Marks Marks

Hrs Hrs Hrs Hrs Hrs Marks Marks Marks Marks Marks Subject Code: CC103-N Subject Title: FUNDAMENTALS OF PROGRAMMING Teaching scheme Total L T P Total Theory Credit Evaluation Scheme Mid Sem Exam CIA Pract. Total Hrs Hrs Hrs Hrs Hrs Marks Marks Marks Marks

More information

Matrices. A Matrix (This one has 2 Rows and 3 Columns) To add two matrices: add the numbers in the matching positions:

Matrices. A Matrix (This one has 2 Rows and 3 Columns) To add two matrices: add the numbers in the matching positions: Matrices A Matrix is an array of numbers: We talk about one matrix, or several matrices. There are many things we can do with them... Adding A Matrix (This one has 2 Rows and 3 Columns) To add two matrices:

More information

Beginning Excel for Windows

Beginning Excel for Windows Beginning Excel for Windows Version: 2002 Academic Computing Support Information Technology Services Tennessee Technological University September 2003 1. Opening Excel for Windows and Setting the Toolbars

More information

Medium Term Plan Year 6: Autumn Term

Medium Term Plan Year 6: Autumn Term Medium Term Plan Year 6: Autumn Term Block A1.a: Multiply integers and decimals by 10, 100 or 1000 AUTUMN TERM Block A1.b: Divide integers by 10, 100 or 1000, and divide decimals by 10 or 100 Block A1.c:

More information

Section 3.2 Measures of Central Tendency MDM4U Jensen

Section 3.2 Measures of Central Tendency MDM4U Jensen Section 3.2 Measures of Central Tendency MDM4U Jensen Part 1: Video This video will review shape of distributions and introduce measures of central tendency. Answer the following questions while watching.

More information

CIS-331 Fall 2013 Exam 1 Name: Total of 120 Points Version 1

CIS-331 Fall 2013 Exam 1 Name: Total of 120 Points Version 1 Version 1 1. (24 Points) Show the routing tables for routers A, B, C, and D. Make sure you account for traffic to the Internet. NOTE: Router E should only be used for Internet traffic. Router A Router

More information

METHODS EXERCISES GuessNumber and Sample run SumAll Sample Run

METHODS EXERCISES GuessNumber and Sample run SumAll Sample Run METHODS EXERCISES Write a method called GuessNumber that receives nothing and returns back nothing. The method first picks a random number from 1-100. The user then keeps guessing as long as their guess

More information

CPSC 121: Models of Computation Assignment #5

CPSC 121: Models of Computation Assignment #5 CPSC 2: Models of Computation Assignment #5 Due: Monday, November 27, 27 at 4:pm Total Marks: 27 Submission Instructions-- read carefully We strongly recommend that assignments be done in groups of 2.

More information

Programming, numerics and optimization

Programming, numerics and optimization Programming, numerics and optimization Lecture A-2: Programming basics II Łukasz Jankowski ljank@ippt.pan.pl Institute of Fundamental Technological Research Room 4.32, Phone +22.8261281 ext. 428 March

More information

arrays Simple Types (Atomic) In this section of notes you will be introduced to a homogeneous composite type, onedimensional 1) Integer 2) Real

arrays Simple Types (Atomic) In this section of notes you will be introduced to a homogeneous composite type, onedimensional 1) Integer 2) Real Arrays In this section of notes you will be introduced to a homogeneous composite type, onedimensional arrays Simple Types (Atomic) 1) Integer 2) Real 3) Char 4) Boolean 1) Homogeneous arrays 2) Heterogeneous

More information

Excel Formulas and Functions

Excel Formulas and Functions Excel Formulas and Functions Formulas Relative cell references Absolute cell references Mixed cell references Naming a cell or range Naming constants Dates and times Natural-language formulas Functions

More information

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

Section 2.2: Introducing Permutations and Factorial Notation

Section 2.2: Introducing Permutations and Factorial Notation Section 2.2: Introducing Permutations and Factorial Notation Factorial Notation is useful when calculating the number of permutations or combinations for specific problems. Permutation An arrangement of

More information

BRANCHING if-else statements

BRANCHING if-else statements BRANCHING if-else statements Conditional Statements A conditional statement lets us choose which statement t t will be executed next Therefore they are sometimes called selection statements Conditional

More information

Pseudocode is an abbreviated version of the actual statement t t (or code ) in the program.

Pseudocode is an abbreviated version of the actual statement t t (or code ) in the program. Pseudocode Pseudocode is an abbreviated version of the actual statement t t (or code ) in the program. It is a type of algorithm in that all steps needed to solve the problem must be listed. 1 While algorithms

More information

Operations and Properties

Operations and Properties . Operations and Properties. OBJECTIVES. Represent the four arithmetic operations using variables. Evaluate expressions using the order of operations. Recognize and apply the properties of addition 4.

More information

Lesson 10. Homework Problem Set Sample Solutions. then Print True else Print False End if. False False True False False False

Lesson 10. Homework Problem Set Sample Solutions. then Print True else Print False End if. False False True False False False Homework Problem Set Sample Solutions 1. Perform the instructions in the following programming code as if you were a computer and your paper were the computer screen. Declare xx integer For all xx from

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

Downloading other workbooks All our workbooks can be downloaded from:

Downloading other workbooks All our workbooks can be downloaded from: Introduction This workbook accompanies the computer skills training workshop. The trainer will demonstrate each skill and refer you to the relevant page at the appropriate time. This workbook can also

More information

CIS-331 Exam 2 Fall 2015 Total of 105 Points Version 1

CIS-331 Exam 2 Fall 2015 Total of 105 Points Version 1 Version 1 1. (20 Points) Given the class A network address 117.0.0.0 will be divided into multiple subnets. a. (5 Points) How many bits will be necessary to address 4,000 subnets? b. (5 Points) What is

More information

Wisconsin Retirement Testing Preparation

Wisconsin Retirement Testing Preparation Wisconsin Retirement Testing Preparation The Wisconsin Retirement System (WRS) is changing its reporting requirements from annual to every pay period starting January 1, 2018. With that, there are many

More information

Question7.How many proper subsets in all are there if a set contains (a) 7 elements (b) 4 elements

Question7.How many proper subsets in all are there if a set contains (a) 7 elements (b) 4 elements Question1. Write the following sets in roster form: 1. A={z: z=3x-8, x W and x0 and x is a multiple of 3 less than 100} Question2. Write the following

More information

Chapter 1. Math review. 1.1 Some sets

Chapter 1. Math review. 1.1 Some sets Chapter 1 Math review This book assumes that you understood precalculus when you took it. So you used to know how to do things like factoring polynomials, solving high school geometry problems, using trigonometric

More information

PROBLEM SOLVING WITH LOOPS. Chapter 7

PROBLEM SOLVING WITH LOOPS. Chapter 7 PROBLEM SOLVING WITH LOOPS Chapter 7 Concept of Repetition Structure Logic It is a computer task, that is used for Repeating a series of instructions many times. Ex. The Process of calculating the Total

More information

1.2 Round-off Errors and Computer Arithmetic

1.2 Round-off Errors and Computer Arithmetic 1.2 Round-off Errors and Computer Arithmetic 1 In a computer model, a memory storage unit word is used to store a number. A word has only a finite number of bits. These facts imply: 1. Only a small set

More information

Homework 3 COSE212, Fall 2018

Homework 3 COSE212, Fall 2018 Homework 3 COSE212, Fall 2018 Hakjoo Oh Due: 10/28, 24:00 Problem 1 (100pts) Let us design and implement a programming language called ML. ML is a small yet Turing-complete functional language that supports

More information

Chapter 7: Linear Functions and Inequalities

Chapter 7: Linear Functions and Inequalities Chapter 7: Linear Functions and Inequalities Index: A: Absolute Value U4L9 B: Step Functions U4L9 C: The Truth About Graphs U4L10 D: Graphs of Linear Inequalities U4L11 E: More Graphs of Linear Inequalities

More information

MML Contest #1 ROUND 1: VOLUME & SURFACES

MML Contest #1 ROUND 1: VOLUME & SURFACES MML Contest # ROUND : VOLUME & SURFACES A) The base of a right pyramid is a square with perimeter 0 inches. The pyramid s altitude is 9 inches. Find the exact volume of the pyramid. A) The volume of a

More information

Section 6: Quadratic Equations and Functions Part 2

Section 6: Quadratic Equations and Functions Part 2 Section 6: Quadratic Equations and Functions Part 2 Topic 1: Observations from a Graph of a Quadratic Function... 147 Topic 2: Nature of the Solutions of Quadratic Equations and Functions... 150 Topic

More information

The Excel worksheet contains 16,384 rows that extend down the worksheet, numbered 1 through

The Excel worksheet contains 16,384 rows that extend down the worksheet, numbered 1 through Microsoft Excel Microsoft Excel allows you to create professional spreadsheets and charts. It performs numerous functions and formulas to assist you in your projects. The Excel screen is devoted to the

More information

Flow Chart. The diagrammatic representation shows a solution to a given problem.

Flow Chart. The diagrammatic representation shows a solution to a given problem. low Charts low Chart A flowchart is a type of diagram that represents an algorithm or process, showing the steps as various symbols, and their order by connecting them with arrows. he diagrammatic representation

More information

Homework 4 Even numbered problem solutions cs161 Summer 2009

Homework 4 Even numbered problem solutions cs161 Summer 2009 Homework 4 Even numbered problem solutions cs6 Summer 2009 Problem 2: (a). No Proof: Given a graph G with n nodes, the minimum spanning tree T has n edges by virtue of being a tree. Any other spanning

More information

Create your first workbook

Create your first workbook Create your first workbook You've been asked to enter data in Excel, but you've never worked with Excel. Where do you begin? Or perhaps you have worked in Excel a time or two, but you still wonder how

More information

MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards

MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards Language Reference Manual Introduction The purpose of

More information

Lesson 11.1 Dilations

Lesson 11.1 Dilations Lesson 11.1 Dilations Key concepts: Scale Factor Center of Dilation Similarity A A dilation changes the size of a figure. B C Pre Image: 1 A A' B C Pre Image: B' C' Image: What does a dilation NOT change?

More information

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points Files to submit: 1. HW3.py This is a PAIR PROGRAMMING Assignment: Work with your partner! For pair

More information

I SEMESTER EXAM : : XI :COMPUTER SCIENCE : MAX MARK a) What is the difference between Hardware and Software? Give one example for each.

I SEMESTER EXAM : : XI :COMPUTER SCIENCE : MAX MARK a) What is the difference between Hardware and Software? Give one example for each. I SEMESTER EXAM : : XI :COMPUTER SCIENCE : MAX MARK 70. a) What is the difference between Hardware and Software? Give one example for each. b) Give two differences between primary and secondary memory.

More information

Making Decisions In Pascal

Making Decisions In Pascal Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action High Level View Of Decision Making For The Computer Is income

More information

! A program is a set of instructions that the. ! It must be translated. ! Variable: portion of memory that stores a value. char

! A program is a set of instructions that the. ! It must be translated. ! Variable: portion of memory that stores a value. char Week 1 Operators, Data Types & I/O Gaddis: Chapters 1, 2, 3 CS 5301 Fall 2016 Jill Seaman Programming A program is a set of instructions that the computer follows to perform a task It must be translated

More information

CSC488S/CSC2107S - Compilers and Interpreters. CSC 488S/CSC 2107S Lecture Notes

CSC488S/CSC2107S - Compilers and Interpreters. CSC 488S/CSC 2107S Lecture Notes CSC 488S/CSC 2107S Lecture Notes These lecture notes are provided for the personal use of students taking CSC488H1S or CSC2107HS in the Winter 2013/2014 term at the University of Toronto Copying for purposes

More information

ITEC2620 Introduction to Data Structures

ITEC2620 Introduction to Data Structures ITEC2620 Introduction to Data Structures Lecture 9b Grammars I Overview How can a computer do Natural Language Processing? Grammar checking? Artificial Intelligence Represent knowledge so that brute force

More information

Plan (next 4 weeks) 1. Fast forward. 2. Rewind. 3. Slow motion. Rapid introduction to what s in OCaml. Go over the pieces individually

Plan (next 4 weeks) 1. Fast forward. 2. Rewind. 3. Slow motion. Rapid introduction to what s in OCaml. Go over the pieces individually Plan (next 4 weeks) 1. Fast forward Rapid introduction to what s in OCaml 2. Rewind 3. Slow motion Go over the pieces individually History, Variants Meta Language Designed by Robin Milner @ Edinburgh Language

More information

Computer Programming: C++

Computer Programming: C++ The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming: C++ Experiment #4 Loops Part II Contents Loop Control Statement

More information

Expressions & interactions Conditionals Solving a problem. binary representation (8 bits)

Expressions & interactions Conditionals Solving a problem. binary representation (8 bits) Expressions & interactions Conditionals Solving a problem binary representation (8 bits) positives: first bit=0 0 = 00000000 1 = 00000001 2 = 00000010 3 = 00000011 4 = 00000100... 127 = 01111111 negatives:

More information

Linear Equations in Two Variables

Linear Equations in Two Variables Section. Linear Equations in Two Variables Section. Linear Equations in Two Variables You should know the following important facts about lines. The graph of b is a straight line. It is called a linear

More information

Chapter 5 test Review Integrated 1

Chapter 5 test Review Integrated 1 Name: Class: _ Date: _ ID: A Chapter 5 test Review Integrated 1 Find the balance in the account. 1. $700 principal earning 2.25%, compounded quarterly, after 6 years a. $72.96 c. $800.87 b. $799.98 d.

More information

3.2-Measures of Center

3.2-Measures of Center 3.2-Measures of Center Characteristics of Center: Measures of center, including mean, median, and mode are tools for analyzing data which reflect the value at the center or middle of a set of data. We

More information

CMPE Experiment 3 Selective Structures

CMPE Experiment 3 Selective Structures Page1 CMPE 108 - Experiment 3 Selective Structures OBJECTIVES: Understand how to edit, compile and execute C computer codes. Understand C programming: sequential and selective structures NOTES: You should

More information

CSc 372. Comparative Programming Languages. 15 : Haskell List Comprehension. Department of Computer Science University of Arizona

CSc 372. Comparative Programming Languages. 15 : Haskell List Comprehension. Department of Computer Science University of Arizona 1/20 CSc 372 Comparative Programming Languages 15 : Haskell List Comprehension Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2013 Christian Collberg 2/20 List Comprehensions

More information

Unit 0: Extending Algebra 1 Concepts

Unit 0: Extending Algebra 1 Concepts 1 What is a Function? Unit 0: Extending Algebra 1 Concepts Definition: ---Function Notation--- Example: f(x) = x 2 1 Mapping Diagram Use the Vertical Line Test Interval Notation A convenient and compact

More information

H1 Series Data Logger / Thermometer

H1 Series Data Logger / Thermometer 1 Series Data Logger / Thermometer Thermocouple Types: K/J/T/E/R/S/N Software Manual Operation Table of Contents... index 1. RS232... index 2. REC... 1 3. CALL... 1 4. CLEAR... 2 5. INTV (RS232)... 3 6.

More information

A.A. 2008/09. Why introduce JavaScript. G. Cecchetti Internet Software Technologies

A.A. 2008/09. Why introduce JavaScript. G. Cecchetti Internet Software Technologies Internet t Software Technologies JavaScript part one IMCNE A.A. 2008/09 Gabriele Cecchetti Why introduce JavaScript To add dynamicity and interactivity to HTML pages 2 What s a script It s a little interpreted

More information

Know the Well-ordering principle: Any set of positive integers which has at least one element contains a smallest element.

Know the Well-ordering principle: Any set of positive integers which has at least one element contains a smallest element. The first exam will be on Wednesday, September 22, 2010. The syllabus will be sections 1.1 and 1.2 in Lax, and the number theory handout found on the class web site, plus the handout on the method of successive

More information

Today s Topics. Team Project Introduce this year s team project. S/SL S/SL, the Syntax/Semantic Language. CISC 458 Winter J.R.

Today s Topics. Team Project Introduce this year s team project. S/SL S/SL, the Syntax/Semantic Language. CISC 458 Winter J.R. Today s Topics Team Project Introduce this year s team project S/SL S/SL, the Syntax/Semantic Language Team Project CISC / CMPE 458 - Project 2019 Implement a compiler for a new language called Mini-Turing

More information

Index Page 1 of 10. Index test size A6. Background. Page 2. Page 3

Index Page 1 of 10. Index test size A6. Background. Page 2. Page 3 Index Page 1 of 10 Index test size A6 Background Page 2 Page 3 Index Page 2 of 10 Assignment 1 Fast Technologies: Background: Fast Technologies[1] (is a manufacturer of solid-state drives (SSD) for desktop

More information

Study Guide for Exam 2

Study Guide for Exam 2 Math 233A Intermediate Algebra Fall 202 Study Guide for Exam 2 Exam 2 is scheduled for Wednesday, October 3 rd. You may use a 3" 5" note card (both sides) and a scientific calculator. You are expected

More information

Excel Tips for Compensation Practitioners Month 1

Excel Tips for Compensation Practitioners Month 1 Excel Tips for Compensation Practitioners Month 1 Introduction This is the first of what will be a weekly column with Excel tips for Compensation Practitioners. These tips will cover functions in Excel

More information

Index Page 1 of 13. Index test size A6. Background. Page 2. Page 3

Index Page 1 of 13. Index test size A6. Background. Page 2. Page 3 Index Page 1 of 13 Index test size A6 Background Page 2 Page 3 Index Page 2 of 13 Assignment 1 Background: Fast Technologies: Fast Technologies[1] (is a manufacturer of solidstate drives (SSD) for desktop

More information

At the end of this lecture you should be able to have a basic overview of fundamental structures in C and be ready to go into details.

At the end of this lecture you should be able to have a basic overview of fundamental structures in C and be ready to go into details. Objective of this lecture: At the end of this lecture you should be able to have a basic overview of fundamental structures in C and be ready to go into details. Fundamental Programming Structures in C

More information

Excel. module. Lesson 1 Create a Worksheet Lesson 2 Create and Revise. Lesson 3 Edit and Format

Excel. module. Lesson 1 Create a Worksheet Lesson 2 Create and Revise. Lesson 3 Edit and Format module 2 Excel Lesson 1 Create a Worksheet Lesson 2 Create and Revise Formulas Lesson 3 Edit and Format Worksheets Lesson 4 Print Worksheets Lesson 5 Modify Workbooks Lesson 6 Create and Modify Charts

More information

UNIVERSITY OF SWAZILAND SUPPLEMENTARY EXAMINATION, JULY 2013

UNIVERSITY OF SWAZILAND SUPPLEMENTARY EXAMINATION, JULY 2013 UNIVERSITY OF SWAZILAND SUPPLEMENTARY EXAMINATION, JULY 2013 Title of Paper : STRUCTURED PROGRAMMING - I Course number: CS243 Time allowed Instructions : Three (3) hours. : (1) Read all the questions in

More information

Problem Solving and Algorithms

Problem Solving and Algorithms Problem Solving and Algorithms Problem Solving We do it all the time Approaches: Less successful Grope blindly toward a solution Fail to complete a chain or reasoning Successful Begin with what is understood

More information