Boolean algebra, conditional statements, loops.

Size: px
Start display at page:

Download "Boolean algebra, conditional statements, loops."

Transcription

1 Boolean algebra, conditional statements, loops. Eugeniy E. Mikhailov The College of William & Mary Lecture 04 Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 1 / 19

2 Boolean algebra Variable of valuable type can have only two values true false Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 2 / 19

3 Boolean algebra Variable of valuable type can have only two values true (Matlab use 1 to indicate it, actually everything but zero) false Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 2 / 19

4 Boolean algebra Variable of valuable type can have only two values true (Matlab use 1 to indicate it, actually everything but zero) false (Matlab uses 0 ) Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 2 / 19

5 Boolean algebra Variable of valuable type can have only two values true (Matlab use 1 to indicate it, actually everything but zero) false (Matlab uses 0 ) There are three logical operators which are used in boolean algebra Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 2 / 19

6 Boolean algebra Variable of valuable type can have only two values true (Matlab use 1 to indicate it, actually everything but zero) false (Matlab uses 0 ) There are three logical operators which are used in boolean algebra - logic not, Matlab true = false false = true Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 2 / 19

7 Boolean algebra Variable of valuable type can have only two values true (Matlab use 1 to indicate it, actually everything but zero) false (Matlab uses 0 ) There are three logical operators which are used in boolean algebra - logic not, Matlab true = false false = true - logic and, Matlab & { true, if A=true and B=true, A B = false, otherwise Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 2 / 19

8 Boolean algebra Variable of valuable type can have only two values true (Matlab use 1 to indicate it, actually everything but zero) false (Matlab uses 0 ) There are three logical operators which are used in boolean algebra - logic not, Matlab true = false false = true - logic and, Matlab & { true, if A=true and B=true, A B = false, otherwise - logic or, Matlab { false, if A=false and B=false, A B = true, otherwise Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 2 / 19

9 Boolean operators precedence in Matlab If A = false, B = true, C = true A B&C Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 3 / 19

10 Boolean operators precedence in Matlab If A = false, B = true, C = true A B&C has highest precedence, then &, and then Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 3 / 19

11 Boolean operators precedence in Matlab If A = false, B = true, C = true A B&C has highest precedence, then &, and then A (( B)&C) Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 3 / 19

12 Boolean operators precedence in Matlab If A = false, B = true, C = true A B&C has highest precedence, then &, and then A (( B)&C) Thus A B&C = false Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 3 / 19

13 Boolean operators precedence in Matlab If A = false, B = true, C = true A B&C has highest precedence, then &, and then A (( B)&C) Thus A B&C = false Cat is an animal and cat is not an animal Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 3 / 19

14 Boolean operators precedence in Matlab If A = false, B = true, C = true A B&C has highest precedence, then &, and then Thus A (( B)&C) A B&C = false Cat is an animal and cat is not an animal is false statement Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 3 / 19

15 Boolean operators precedence in Matlab If A = false, B = true, C = true A B&C has highest precedence, then &, and then Thus A (( B)&C) A B&C = false Cat is an animal and cat is not an animal is false statement Z &Z = Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 3 / 19

16 Boolean operators precedence in Matlab If A = false, B = true, C = true A B&C has highest precedence, then &, and then Thus A (( B)&C) A B&C = false Cat is an animal and cat is not an animal is false statement Z &Z = false Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 3 / 19

17 Boolean logic examples There is an island, which is populated by two kind of people: liars and truthlovers. Liars always lie and never speak a word of truth. Truthlovers always speak only truth. Suppose, you are landed on this island and met a person. What will be the answer to your question Who are you? Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 4 / 19

18 Boolean logic examples There is an island, which is populated by two kind of people: liars and truthlovers. Liars always lie and never speak a word of truth. Truthlovers always speak only truth. Suppose, you are landed on this island and met a person. What will be the answer to your question Who are you? The answer always will be Truthlover. Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 4 / 19

19 Boolean logic examples There is an island, which is populated by two kind of people: liars and truthlovers. Liars always lie and never speak a word of truth. Truthlovers always speak only truth. Suppose, you are landed on this island and met a person. What will be the answer to your question Who are you? The answer always will be Truthlover. Now you see a person who answers to your question. I am a liar. Is it possible? Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 4 / 19

20 Boolean logic examples There is an island, which is populated by two kind of people: liars and truthlovers. Liars always lie and never speak a word of truth. Truthlovers always speak only truth. Suppose, you are landed on this island and met a person. What will be the answer to your question Who are you? The answer always will be Truthlover. Now you see a person who answers to your question. I am a liar. Is it possible? This makes a paradox and should not ever happen on this island. Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 4 / 19

21 Matlab boolean logic examples & 12= Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 5 / 19

22 Matlab boolean logic examples & 12= e-6 = Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 5 / 19

23 Matlab boolean logic examples & 12= e-6 = 0 Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 5 / 19

24 Matlab boolean logic examples & 12= e-6 = 0 >> B=[ , 0; , 12] B = Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 5 / 19

25 Matlab boolean logic examples & 12= e-6 = 0 >> B=[ , 0; , 12] B = ~B Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 5 / 19

26 Matlab boolean logic examples & 12= e-6 = 0 >> B=[ , 0; , 12] B = ~B ans = Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 5 / 19

27 Matlab boolean logic examples & 12= e-6 = 0 >> B=[ , 0; , 12] B = ~B ans = B ~B Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 5 / 19

28 Matlab boolean logic examples & 12= e-6 = 0 >> B=[ , 0; , 12] B = ~B ans = B ~B To be or not to be ans = Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 5 / 19

29 Matlab boolean logic examples >> B=[ , 0; , 12] B = >> A=[56, 655; 0, 24.4] A = Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 6 / 19

30 Matlab boolean logic examples >> B=[ , 0; , 12] B = >> A=[56, 655; 0, 24.4] A = B&A Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 6 / 19

31 Matlab boolean logic examples >> B=[ , 0; , 12] B = >> A=[56, 655; 0, 24.4] A = B&A ans = Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 6 / 19

32 Matlab boolean logic examples >> B=[ , 0; , 12] B = >> A=[56, 655; 0, 24.4] A = B&A A ~B ans = Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 6 / 19

33 Matlab boolean logic examples >> B=[ , 0; , 12] B = >> A=[56, 655; 0, 24.4] A = B&A ans = A ~B ans = Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 6 / 19

34 Comparison operators Math Matlab = == double equal sign! = < < <= > > >= Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 7 / 19

35 Comparison operators Math x=[1,2,3,4,5] x = Matlab = == double equal sign! = < < <= > > >= Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 7 / 19

36 Comparison operators Math x=[1,2,3,4,5] x = x >= 3 Matlab = == double equal sign! = < < <= > > >= Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 7 / 19

37 Comparison operators Math x=[1,2,3,4,5] x = x >= 3 ans = Matlab = == double equal sign! = < < <= > > >= Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 7 / 19

38 Comparison operators Math x=[1,2,3,4,5] x = Matlab = == double equal sign! = < < <= > > >= x >= 3 ans = % chose such x where x>=3 x(x >= 3) Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 7 / 19

39 Comparison operators Math x=[1,2,3,4,5] x = Matlab = == double equal sign! = < < <= > > >= x >= 3 ans = % chose such x where x>=3 x(x >= 3) ans = Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 7 / 19

40 Comparison with matrices >> A=[1,2;3,4] A = >> B=[33,11;53,42] B = Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 8 / 19

41 Comparison with matrices >> A=[1,2;3,4] A = >> B=[33,11;53,42] B = A>=2 Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 8 / 19

42 Comparison with matrices >> A=[1,2;3,4] A = >> B=[33,11;53,42] B = A>=2 ans = Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 8 / 19

43 Comparison with matrices >> A=[1,2;3,4] A = >> B=[33,11;53,42] B = A>=2 A(A>=2) ans = Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 8 / 19

44 Comparison with matrices >> A=[1,2;3,4] A = >> B=[33,11;53,42] B = A>=2 ans = A(A>=2) ans = Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 8 / 19

45 Comparison with matrices >> A=[1,2;3,4] A = >> B=[33,11;53,42] B = A>=2 ans = A(A>=2) ans = B(A>=2) Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 8 / 19

46 Comparison with matrices >> A=[1,2;3,4] A = >> B=[33,11;53,42] B = A>=2 ans = A(A>=2) ans = B(A>=2) ans = Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 8 / 19

47 if-else- statement if expression this part is executed only if expression is true else this part is executed only if expression is false Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 9 / 19

48 if-else- statement if expression this part is executed only if expression is true else this part is executed only if expression is false if hungry buy some food else keep working Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 9 / 19

49 if-else- statement if expression this part is executed only if expression is true else this part is executed only if expression is false if hungry buy some food else keep working if (x>=0) y=sqrt(x); else error( cannot do ); Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 9 / 19

50 Common mistake in the if statement if (x=y) D=4; Z=45; C=12; else D=2; Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

51 Common mistake in the if statement if (x=y) D=4; Z=45; C=12; else D=2; the value of D is always 4, except the case when y=0 Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

52 Common mistake in the if statement if (x=y) D=4; Z=45; C=12; else D=2; the value of D is always 4, except the case when y=0 someone used assignment operator (=) instead of comparison (==) Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

53 Short form of if- statement if expression this part is executed only if expression is true Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

54 Short form of if- statement if expression this part is executed only if expression is true if won a million go party Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

55 Short form of if- statement if expression this part is executed only if expression is true if won a million go party if (deviation<=0) exit; Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

56 The while statement while expression this part is executed while expression is true Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

57 The while statement while expression this part is executed while expression is true while hungry keep eating Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

58 The while statement while expression this part is executed while expression is true while hungry keep eating i=1; while (i<=10) c=a+b; z=c*4+5; i=i+2; Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

59 The while statement while expression this part is executed while expression is true while hungry keep eating i=1; while (i<=10) c=a+b; z=c*4+5; i=i+2; while loop is extremely useful but they are not guaranteed to finish. For a bit more complicated conditional statement and loop it is impossible to predict if the loop will finish. Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

60 The while statement while expression this part is executed while expression is true while hungry keep eating i=1; while (i<=10) c=a+b; z=c*4+5; i=i+2; while loop is extremely useful but they are not guaranteed to finish. For a bit more complicated conditional statement and loop it is impossible to predict if the loop will finish. Yet another common mistake is i=1; while (i<=10) c=a+b; Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

61 The while statement while expression this part is executed while expression is true while hungry keep eating i=1; while (i<=10) c=a+b; z=c*4+5; i=i+2; while loop is extremely useful but they are not guaranteed to finish. For a bit more complicated conditional statement and loop it is impossible to predict if the loop will finish. Yet another common mistake is i=1; while (i<=10) c=a+b; not updating the term leading to fulfillment of the while condition Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

62 The for statement for variable = expression do something In this case variable is assigned concequently with columns of the expression, and then statements inside of the loop are executed Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

63 The for statement for variable = expression do something In this case variable is assigned concequently with columns of the expression, and then statements inside of the loop are executed sum=0; x=[1,3,5,6] for v=x sum=sum+v; >> sum sum = 15 Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

64 The for statement for variable = expression do something In this case variable is assigned concequently with columns of the expression, and then statements inside of the loop are executed sum=0; x=[1,3,5,6] for v=x sum=sum+v; >> sum sum = 15 for loops are guaranteed to complete after predictable number of iterations (the amount of columns in expression). Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

65 Example 100 S = i = i=1 Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

66 Example 100 S = i = i=1 S=0; i=1; while(i<=100) S=S+i; i=i+1; Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

67 Example 100 S = i = i=1 S=0; i=1; while(i<=100) S=S+i; i=i+1; S=0; for i=1:100 S=S+i; Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

68 Example S = k=1 a k Until k<=100 and a k < 10 5, where a k = k k. Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

69 Example S = k=1 a k Until k<=100 and a k < 10 5, where a k = k k. S=0; k=1; while( (k<=100) & (k^-k >= 1e-5) ) S=S+k^-k; k=k+1; Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

70 Example S = k=1 a k Until k<=100 and a k < 10 5, where a k = k k. S=0; k=1; while( (k<=100) & (k^-k >= 1e-5) ) S=S+k^-k; k=k+1; >> S S = Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

71 Example S = k=1 a k Until k<=100 and a k < 10 5, where a k = k k. S=0; k=1; while( (k<=100) & (k^-k >= 1e-5) ) S=S+k^-k; k=k+1; >> S S = S=0; k=1; while( k<=100 ) a_k=k^-k; if (a_k < 1e-5) break; S=S+a_k; k=k+1; Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

72 Example S = k=1 a k Until k<=100 and a k < 10 5, where a k = k k. S=0; k=1; while( (k<=100) & (k^-k >= 1e-5) ) S=S+k^-k; k=k+1; >> S S = S=0; k=1; while( k<=100 ) a_k=k^-k; if (a_k < 1e-5) break; S=S+a_k; k=k+1; >> S S = Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

73 Same example with for loop S = k=1 a k Until k<=100 and a k < 10 5, where a k = k k. Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

74 Same example with for loop S = k=1 a k Until k<=100 and a k < 10 5, where a k = k k. S=0; for k=1:100 a_k=k^-k; if (a_k < 1e-5) break; S=S+a_k; Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

75 Same example with for loop S = k=1 a k Until k<=100 and a k < 10 5, where a k = k k. S=0; for k=1:100 a_k=k^-k; if (a_k < 1e-5) break; S=S+a_k; >> S S = Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

76 Interest rate related example Suppose bank gave you 50% interest rate (let s call it x ), and you put one dollar in. How much would you get at the of the year? one payment at the of the year M 1 = 1 (1 + x) = 1 (1 +.5) = 1.5 Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

77 Interest rate related example Suppose bank gave you 50% interest rate (let s call it x ), and you put one dollar in. How much would you get at the of the year? one payment at the of the year M 1 = 1 (1 + x) = 1 (1 +.5) = 1.5 interest payment every half a year M 2 = 1 (1 + x/2) (1 + x/2) = 1 (1 +.5/2) 2 = Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

78 Interest rate related example Suppose bank gave you 50% interest rate (let s call it x ), and you put one dollar in. How much would you get at the of the year? one payment at the of the year M 1 = 1 (1 + x) = 1 (1 +.5) = 1.5 interest payment every half a year M 2 = 1 (1 + x/2) (1 + x/2) = 1 (1 +.5/2) 2 = interest payment every month M 12 = 1 (1 + x/12) 12 = Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

79 Interest rate related example Now let s find how you money growth (M N ) deps on the number of payments per year N_max=100; N=1:N_max; M=0*(N); x=.5; for i=n M(i)=(1+x/i)^i; plot(n,m, - ); xlabel( N, number of payments per year ); ylabel( Money grows ); title( Money grows vs number of payments per year ); Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

80 Interest rate related example Eugeniy Mikhailov (W&M) Practical Computing Lecture / 19

Functions and scripts

Functions and scripts Functions and scripts Eugeniy E. Mikhailov The College of William & Mary Lecture 04 Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 1 / 14 Scripts Script is the sequence of the Matlab expressions

More information

Sorting. Bubble sort method. Bubble sort properties. Quick sort method. Notes. Eugeniy E. Mikhailov. Lecture 27. Notes. Notes

Sorting. Bubble sort method. Bubble sort properties. Quick sort method. Notes. Eugeniy E. Mikhailov. Lecture 27. Notes. Notes Sorting Eugeniy E. Mikhailov The College of William & Mary Lecture 7 Eugeniy Mikhailov (W&M) Practical Computing Lecture 7 1 / 18 Bubble sort method Some one give us a vector of unsorted numbers. We want

More information

Introduction to Matlab. Matlab variable types. Matlab variable types. Matlab variable types. Notes. Eugeniy E. Mikhailov. Lecture 02. Notes.

Introduction to Matlab. Matlab variable types. Matlab variable types. Matlab variable types. Notes. Eugeniy E. Mikhailov. Lecture 02. Notes. Introduction to Matlab Eugeniy E. Mikhailov The College of William & Mary Lecture 02 Eugeniy Mikhailov (W&M) Practical Computing Lecture 02 1 / 26 Matlab variable types Eugeniy Mikhailov (W&M) Practical

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Eugeniy E. Mikhailov The College of William & Mary Lecture 02 Eugeniy Mikhailov (W&M) Practical Computing Lecture 02 1 / 27 Matlab variable types Eugeniy Mikhailov (W&M) Practical

More information

SYNERGY INSTITUTE OF ENGINEERING & TECHNOLOGY,DHENKANAL LECTURE NOTES ON DIGITAL ELECTRONICS CIRCUIT(SUBJECT CODE:PCEC4202)

SYNERGY INSTITUTE OF ENGINEERING & TECHNOLOGY,DHENKANAL LECTURE NOTES ON DIGITAL ELECTRONICS CIRCUIT(SUBJECT CODE:PCEC4202) Lecture No:5 Boolean Expressions and Definitions Boolean Algebra Boolean Algebra is used to analyze and simplify the digital (logic) circuits. It uses only the binary numbers i.e. 0 and 1. It is also called

More information

Objectives: 1- Bolean Algebra. Eng. Ayman Metwali

Objectives: 1- Bolean Algebra. Eng. Ayman Metwali Objectives: Chapter 3 : 1- Boolean Algebra Boolean Expressions Boolean Identities Simplification of Boolean Expressions Complements Representing Boolean Functions 2- Logic gates 3- Digital Components 4-

More information

COMP Intro to Logic for Computer Scientists. Lecture 2

COMP Intro to Logic for Computer Scientists. Lecture 2 COMP 1002 Intro to Logic for Computer Scientists Lecture 2 B 5 2 J Language of logic: building blocks Proposition: A sentence that can be true or false. A: It is raining in St. John s right now. B: 2+2=7

More information

Concepts Review. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++.

Concepts Review. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++. Concepts Review 1. An algorithm is a sequence of steps to solve a problem. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++. 3. A flowchart is the graphical

More information

Lecture Transcript While and Do While Statements in C++

Lecture Transcript While and Do While Statements in C++ Lecture Transcript While and Do While Statements in C++ Hello and welcome back. In this lecture we are going to look at the while and do...while iteration statements in C++. Here is a quick recap of some

More information

Lecture 3: Binary Subtraction, Switching Algebra, Gates, and Algebraic Expressions

Lecture 3: Binary Subtraction, Switching Algebra, Gates, and Algebraic Expressions EE210: Switching Systems Lecture 3: Binary Subtraction, Switching Algebra, Gates, and Algebraic Expressions Prof. YingLi Tian Feb. 5/7, 2019 Department of Electrical Engineering The City College of New

More information

Loops and Conditionals. HORT Lecture 11 Instructor: Kranthi Varala

Loops and Conditionals. HORT Lecture 11 Instructor: Kranthi Varala Loops and Conditionals HORT 59000 Lecture 11 Instructor: Kranthi Varala Relational Operators These operators compare the value of two expressions and returns a Boolean value. Beware of comparing across

More information

Lecture 9. Assignment. Logical Operations. Logical Operations - Motivation 2/8/18

Lecture 9. Assignment. Logical Operations. Logical Operations - Motivation 2/8/18 Assignment Lecture 9 Logical Operations Formatted Print Printf Increment and decrement Read through 3.9, 3.10 Read 4.1. 4.2, 4.3 Go through checkpoint exercise 4.1 Logical Operations - Motivation Logical

More information

Computer Project #2 (Matrix Operations)

Computer Project #2 (Matrix Operations) Math 0280 Introduction to Matrices and Linear Algebra Fall 2006 Computer Project #2 (Matrix Operations) SCHEDULE: This assignment is due in class on Monday, October 23, 2006. One submission per group is

More information

Advanced Software Testing Understanding Code Coverage

Advanced Software Testing Understanding Code Coverage Advanced Software Testing Understanding Code Coverage Advanced Software Testing A series of webinars, this one excerpted from Advanced Software Testing: V3, a book for technical test analysts, programmers,

More information

A gentle introduction to Matlab

A gentle introduction to Matlab A gentle introduction to Matlab The Mat in Matlab does not stand for mathematics, but for matrix.. all objects in matlab are matrices of some sort! Keep this in mind when using it. Matlab is a high level

More information

Simulated annealing/metropolis and genetic optimization

Simulated annealing/metropolis and genetic optimization Simulated annealing/metropolis and genetic optimization Eugeniy E. Mikhailov The College of William & Mary Lecture 18 Eugeniy Mikhailov (W&M) Practical Computing Lecture 18 1 / 8 Nature s way to find a

More information

CSE 143. Computer Programming II

CSE 143. Computer Programming II Adam Blank Lecture 17 Winter 2015 CSE 143 Computer Programming II CSE 143: Computer Programming II Recursive Backtracking Recursive Backtracking Outline 1 Sentence Splitter 2 Playing With Boolean Expressions

More information

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan Lecture 08-1 Programming in C++ PART 1 By Assistant Professor Dr. Ali Kattan 1 The Conditional Operator The conditional operator is similar to the if..else statement but has a shorter format. This is useful

More information

Flow of Control: Loops

Flow of Control: Loops Flow of Control: Loops Chapter 4 Objectives Design a loop Use while, do, and for in a program Use the for-each with enumerations Use assertion checks Use repetition in a graphics program Use drawstring

More information

bool bool - either true or false

bool bool - either true or false Strings & Branching bool bool - either true or false You have the common math comparisons: > (greater than), e.g. 7 > 2.5 is true == (equals), e.g. 5 == 4 is false

More information

Announcements. Project 5 is on the street. Second part is essay questions for CoS teaming requirements.

Announcements. Project 5 is on the street. Second part is essay questions for CoS teaming requirements. Announcements Project 5 is on the street. Second part is essay questions for CoS teaming requirements. The first part you do as a team The CoS essay gets individually answered and has separate submission

More information

Activity Boolean Algebra

Activity Boolean Algebra Activity 2.1.6 Boolean Algebra Introduction Have you ever had an idea that you thought was so unique that when you told someone else about it, you simply could not believe they thought you were wasting

More information

Haskell Review COMP360

Haskell Review COMP360 Haskell Review COMP360 Some people talk in their sleep. Lecturers talk while other people sleep Albert Camus Remaining Schedule Friday, April 7 Haskell Monday, April 10 Logic Programming read chapter 12

More information

Structure Array 1 / 50

Structure Array 1 / 50 Structure Array A structure array is a data type that groups related data using data containers called fields. Each field can contain any type of data. Access data in a structure using dot notation of

More information

Control Structures. March 1, Dr. Mihail. (Dr. Mihail) Control March 1, / 28

Control Structures. March 1, Dr. Mihail. (Dr. Mihail) Control March 1, / 28 Control Structures Dr. Mihail March 1, 2015 (Dr. Mihail) Control March 1, 2015 1 / 28 Overview So far in this course, MATLAB programs consisted of a ordered sequence of mathematical operations, functions,

More information

Propositional Logic:

Propositional Logic: CS2209A 2017 Applied Logic for Computer Science Lecture 2 Propositional Logic: Syntax, semantics, truth table Instructor: Yu Zhen Xie Language of logic: building blocks Proposition: A sentence that can

More information

CS470: Computer Architecture. AMD Quad Core

CS470: Computer Architecture. AMD Quad Core CS470: Computer Architecture Yashwant K. Malaiya, Professor malaiya@cs.colostate.edu AMD Quad Core 1 Architecture Layers Building blocks Gates, flip-flops Functional bocks: Combinational, Sequential Instruction

More information

Chapter 4: Programming with MATLAB

Chapter 4: Programming with MATLAB Chapter 4: Programming with MATLAB Topics Covered: Programming Overview Relational Operators and Logical Variables Logical Operators and Functions Conditional Statements For Loops While Loops Debugging

More information

Logic-based test coverage

Logic-based test coverage Eduardo Marques, Vasco Thudichum Vasconcelos Logic-based test coverage Basic approach Clauses and predicates Basic coverage criteria: CC, PC, CoC Structural logic coverage of source code Logic coverage

More information

Other useful tools. Eugeniy E. Mikhailov. Lecture 11. The College of William & Mary. Eugeniy Mikhailov (W&M) Practical Computing Lecture 11 1 / 9

Other useful tools. Eugeniy E. Mikhailov. Lecture 11. The College of William & Mary. Eugeniy Mikhailov (W&M) Practical Computing Lecture 11 1 / 9 Other useful tools Eugeniy E. Mikhailov The College of William & Mary Lecture 11 Eugeniy Mikhailov (W&M) Practical Computing Lecture 11 1 / 9 Specialization is... A human being should be able to change

More information

CS106X Handout 03 Autumn 2012 September 24 th, 2012 Getting Started

CS106X Handout 03 Autumn 2012 September 24 th, 2012 Getting Started CS106X Handout 03 Autumn 2012 September 24 th, 2012 Getting Started Handout written by Julie Zelenski, Mehran Sahami, Robert Plummer, and Jerry Cain. After today s lecture, you should run home and read

More information

Flow of Control: Loops. Objectives. Java Loop Statements: Outline 6/27/2014. Chapter 4

Flow of Control: Loops. Objectives. Java Loop Statements: Outline 6/27/2014. Chapter 4 Flow of Control: Loops Chapter 4 Objectives Design a loop Use while, do, and for in a program Use the for-each with enumerations Use assertion checks Use repetition in a graphics program Use drawstring

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

(Refer Slide Time 3:31)

(Refer Slide Time 3:31) Digital Circuits and Systems Prof. S. Srinivasan Department of Electrical Engineering Indian Institute of Technology Madras Lecture - 5 Logic Simplification In the last lecture we talked about logic functions

More information

CS100J, Fall 2003 Preparing for Prelim 1: Monday, 29 Sept., 7:30 9:00PM

CS100J, Fall 2003 Preparing for Prelim 1: Monday, 29 Sept., 7:30 9:00PM CS100J, Fall 2003 Preparing for Prelim 1: Monday, 29 Sept., 7:30 9:00PM This handout explains what you have to know for the first prelim. Terms and their meaning Below, we summarize the terms you should

More information

ENGIN 112 Intro to Electrical and Computer Engineering

ENGIN 112 Intro to Electrical and Computer Engineering ENGIN 2 Intro to Electrical and Computer Engineering Lecture 5 Boolean Algebra Overview Logic functions with s and s Building digital circuitry Truth tables Logic symbols and waveforms Boolean algebra

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

QUESTION BANK FOR TEST

QUESTION BANK FOR TEST CSCI 2121 Computer Organization and Assembly Language PRACTICE QUESTION BANK FOR TEST 1 Note: This represents a sample set. Please study all the topics from the lecture notes. Question 1. Multiple Choice

More information

Recitation Session 6

Recitation Session 6 Recitation Session 6 CSE341 Computer Organization University at Buffalo radhakri@buffalo.edu March 11, 2016 CSE341 Computer Organization Recitation Session 6 1/26 Recitation Session Outline 1 Overview

More information

Menu. Algebraic Simplification - Boolean Algebra EEL3701 EEL3701. MSOP, MPOS, Simplification

Menu. Algebraic Simplification - Boolean Algebra EEL3701 EEL3701. MSOP, MPOS, Simplification Menu Minterms & Maxterms SOP & POS MSOP & MPOS Simplification using the theorems/laws/axioms Look into my... 1 Definitions (Review) Algebraic Simplification - Boolean Algebra Minterms (written as m i ):

More information

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018 Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 1: Types and Control Flow http://courses.cs.cornell.edu/cs2110/2018su Lecture 1 Outline 2 Languages Overview Imperative

More information

Math 1526: Excel Lab 5 Summer 2004

Math 1526: Excel Lab 5 Summer 2004 Math 5: Excel Lab 5 Summer Matrix Algebra In order to complete matrix operations using Excel, you must learn how to use arrays. First you must learn how to enter a matrix into a spreadsheet. For practice,

More information

Unit 7. 'while' Loops

Unit 7. 'while' Loops 1 Unit 7 'while' Loops 2 Control Structures We need ways of making decisions in our program To repeat code until we want it to stop To only execute certain code if a condition is true To execute one segment

More information

Fall 2014 MAT 375 Numerical Methods. Introduction to Programming using MATLAB

Fall 2014 MAT 375 Numerical Methods. Introduction to Programming using MATLAB Fall 2014 MAT 375 Numerical Methods Introduction to Programming using MATLAB Some useful links 1 The MOST useful link: www.google.com 2 MathWorks Webcite: www.mathworks.com/help/matlab/ 3 Wikibooks on

More information

STUDENT LESSON A14 Boolean Algebra and Loop Boundaries

STUDENT LESSON A14 Boolean Algebra and Loop Boundaries STUDENT LESSON A14 Boolean Algebra and Loop Boundaries Java Curriculum for AP Computer Science, Student Lesson A14 1 STUDENT LESSON A14 Boolean Algebra and Loop Boundaries INTRODUCTION: Conditional loops

More information

Project 2: How Parentheses and the Order of Operations Impose Structure on Expressions

Project 2: How Parentheses and the Order of Operations Impose Structure on Expressions MAT 51 Wladis Project 2: How Parentheses and the Order of Operations Impose Structure on Expressions Parentheses show us how things should be grouped together. The sole purpose of parentheses in algebraic

More information

MATH 676. Finite element methods in scientific computing

MATH 676. Finite element methods in scientific computing MATH 676 Finite element methods in scientific computing Wolfgang Bangerth, Texas A&M University Lecture 41.25: Parallelization on a cluster of distributed memory machines Part 2: Debugging with MPI Debugging

More information

AMS 27L LAB #2 Winter 2009

AMS 27L LAB #2 Winter 2009 AMS 27L LAB #2 Winter 2009 Plots and Matrix Algebra in MATLAB Objectives: 1. To practice basic display methods 2. To learn how to program loops 3. To learn how to write m-files 1 Vectors Matlab handles

More information

Chapter 2 Operations and Expressions

Chapter 2 Operations and Expressions Chapter Operations and Expressions Homework.. Substitute for x in x. Substitute for x in x. Substitute for x in x 9 : : : 9 8. Substitute for x in 0 x : 0 0. Substitute for x in x x. Substitute for x in

More information

Announcements. HW 0 due tonight (check that it compiles on CSE labs) (make sure you submit the code part)

Announcements. HW 0 due tonight (check that it compiles on CSE labs) (make sure you submit the code part) Loops Ch 3.3-3.4 Announcements HW 0 due tonight (check that it compiles on CSE labs) (make sure you submit the code part) Scope (See last time: scope.cpp) If... if... else! When in doubt, use parenthesis

More information

Finite Math - J-term Homework. Section Inverse of a Square Matrix

Finite Math - J-term Homework. Section Inverse of a Square Matrix Section.5-77, 78, 79, 80 Finite Math - J-term 017 Lecture Notes - 1/19/017 Homework Section.6-9, 1, 1, 15, 17, 18, 1, 6, 9, 3, 37, 39, 1,, 5, 6, 55 Section 5.1-9, 11, 1, 13, 1, 17, 9, 30 Section.5 - Inverse

More information

DCS/100: Procedural Programming

DCS/100: Procedural Programming DCS/100: wk 5 p.1/33 DCS/100: Procedural Programming Week 5: While Loops Queen Mary, University of London DCS/100: wk 5 p.2/33 Last week You should now be able to: write programs that follow instructions

More information

Announcements. Lab 1 this week! Homework posted Wednesday (late)

Announcements. Lab 1 this week! Homework posted Wednesday (late) C++ Basics Announcements Lab 1 this week! Homework posted Wednesday (late) Avoid errors To remove your program of bugs, you should try to test your program on a wide range of inputs Typically it is useful

More information

4. Flow of Control: Loops

4. Flow of Control: Loops 4. Flow of Control: Loops Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich http://seal.ifi.uzh.ch/info1 Objectives n Design a loop n Use while, and for in a program Java Loop Statements

More information

4. Flow of Control: Loops. Objectives. Java Loop Statements 10/10/12. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich

4. Flow of Control: Loops. Objectives. Java Loop Statements 10/10/12. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich 4. Flow of Control: Loops Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich http://seal.ifi.uzh.ch/info1 Objectives n Design a loop n Use while, and for in a program Java Loop Statements

More information

(Refer Slide Time 04:53)

(Refer Slide Time 04:53) Programming and Data Structure Dr.P.P.Chakraborty Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture 26 Algorithm Design -1 Having made a preliminary study

More information

Henry Lin, Department of Electrical and Computer Engineering, California State University, Bakersfield Lecture 7 (Digital Logic) July 24 th, 2012

Henry Lin, Department of Electrical and Computer Engineering, California State University, Bakersfield Lecture 7 (Digital Logic) July 24 th, 2012 Henry Lin, Department of Electrical and Computer Engineering, California State University, Bakersfield Lecture 7 (Digital Logic) July 24 th, 2012 1 Digital vs Analog Digital signals are binary; analog

More information

Announcements. HW0 is posted on schedule, due next Friday at 9pm (pretty easy)

Announcements. HW0 is posted on schedule, due next Friday at 9pm (pretty easy) Branching Announcements HW0 is posted on schedule, due next Friday at 9pm (pretty easy) Office hours (attempt problems before going): - HW only or Lab only (check calendar) - Write name on whiteboard if

More information

IEEE Floating-Point Representation 1

IEEE Floating-Point Representation 1 IEEE Floating-Point Representation 1 x = ( 1) s M 2 E The sign s determines whether the number is negative (s = 1) or positive (s = 0). The significand M is a fractional binary number that ranges either

More information

Introduction in MATLAB (TSRT04)

Introduction in MATLAB (TSRT04) VT2 2019 Division of Communication Systems Department of Electrical Engineering (ISY) Linköping University, Sweden www.commsys.isy.liu.se/en/student/kurser/tsrt04 About the Course MATLAB Basics Vectors

More information

Computers and programming languages introduction

Computers and programming languages introduction Computers and programming languages introduction Eugeniy E. Mikhailov The College of William & Mary Lecture 01 Eugeniy Mikhailov (W&M) Practical Computing Lecture 01 1 / 19 Class goals and structure Primary

More information

Lecture 8. Divided Differences,Least-Squares Approximations. Ceng375 Numerical Computations at December 9, 2010

Lecture 8. Divided Differences,Least-Squares Approximations. Ceng375 Numerical Computations at December 9, 2010 Lecture 8, Ceng375 Numerical Computations at December 9, 2010 Computer Engineering Department Çankaya University 8.1 Contents 1 2 3 8.2 : These provide a more efficient way to construct an interpolating

More information

Chapter 2 Exploring Data with Graphs and Numerical Summaries

Chapter 2 Exploring Data with Graphs and Numerical Summaries Chapter 2 Exploring Data with Graphs and Numerical Summaries Constructing a Histogram on the TI-83 Suppose we have a small class with the following scores on a quiz: 4.5, 5, 5, 6, 6, 7, 8, 8, 8, 8, 9,

More information

Shuli s Math Problem Solving Column

Shuli s Math Problem Solving Column huli s Math Problem olving Column Volume, Issue March, 009 Edited and uthored by huli ong Colorado prings, Colorado shuli_song@yahoo.com Content. Math Trick: Mental Calculation: aa bc. Math Competition

More information

ENGINEERS ACADEMY. 7. Given Boolean theorem. (a) A B A C B C A B A C. (b) AB AC BC AB BC. (c) AB AC BC A B A C B C.

ENGINEERS ACADEMY. 7. Given Boolean theorem. (a) A B A C B C A B A C. (b) AB AC BC AB BC. (c) AB AC BC A B A C B C. Digital Electronics Boolean Function QUESTION BANK. The Boolean equation Y = C + C + C can be simplified to (a) (c) A (B + C) (b) AC (d) C. The Boolean equation Y = (A + B) (A + B) can be simplified to

More information

for all x, the assertion P(x) is false. there exists x, for which the assertion P(x) is true.

for all x, the assertion P(x) is false. there exists x, for which the assertion P(x) is true. You can t prove a predicate is true because a predicate is not an assertion, you can t prove it is valid as it is not a deduction! If someone asks you to prove P(x), it is not totally clear what they mean.

More information

4. Flow of Control: Loops. Objectives. Java Loop Statements: Outline 10/3/11. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich

4. Flow of Control: Loops. Objectives. Java Loop Statements: Outline 10/3/11. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich 4. Flow of Control: Loops Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich http://seal.ifi.uzh.ch/info1 Objectives! Design a loop! Use while, and for in a program Java Loop Statements:

More information

4. Flow of Control: Loops

4. Flow of Control: Loops 4. Flow of Control: Loops Prof. Dr. Harald Gall Institut für Informatik Universität Zürich http://seal.ifi.uzh.ch Objectives Design a loop Use while, and for in a program Java Loop Statements: Outline

More information

Files and File Management Scripts Logical Operations Conditional Statements

Files and File Management Scripts Logical Operations Conditional Statements Files and File Management Scripts Logical Operations Conditional Statements Files and File Management Matlab provides a group of commands to manage user files pwd: Print working directory displays the

More information

Ordinary Differential Equation Solver Language (ODESL) Reference Manual

Ordinary Differential Equation Solver Language (ODESL) Reference Manual Ordinary Differential Equation Solver Language (ODESL) Reference Manual Rui Chen 11/03/2010 1. Introduction ODESL is a computer language specifically designed to solve ordinary differential equations (ODE

More information

8.3 Common Loop Patterns

8.3 Common Loop Patterns Lecture 17 Topics: Chapter 8. Loop Structures and Booleans 8.3 (Continues) nested loops 8.4. Computing with booleans 8.5 Other common structures: post-test, loop and half. 1 8.3 Common Loop Patterns Nested

More information

Computational Mathematics

Computational Mathematics Computational Mathematics Hilary Term Lecture 1: Programming Andrew Thompson Outline for Today: Schedule this term Review Introduction to programming Examples Arrays: the foundation of MATLAB Basics MATLAB

More information

CS 112: Intro to Comp Prog

CS 112: Intro to Comp Prog CS 112: Intro to Comp Prog Importing modules Branching Loops Program Planning Arithmetic Program Lab Assignment #2 Upcoming Assignment #1 Solution CODE: # lab1.py # Student Name: John Noname # Assignment:

More information

From: Robert Sharpley Subject: Homeworks #6 Date: February 22, :09:53 AM EST Cc: Robert Sharpley

From: Robert Sharpley Subject: Homeworks #6 Date: February 22, :09:53 AM EST Cc: Robert Sharpley From: Robert Sharpley Subject: Homeworks #6 Date: February 22, 2006 9:09:53 AM EST Cc: Robert Sharpley %% Homework #5 - Solutions %% Here is a matlab code

More information

18.02 Multivariable Calculus Fall 2007

18.02 Multivariable Calculus Fall 2007 MIT OpenCourseWare http://ocw.mit.edu 18.02 Multivariable Calculus Fall 2007 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 18.02 Problem Set 4 Due Thursday

More information

Chapter 3. Boolean Algebra and Digital Logic

Chapter 3. Boolean Algebra and Digital Logic Chapter 3 Boolean Algebra and Digital Logic Chapter 3 Objectives Understand the relationship between Boolean logic and digital computer circuits. Learn how to design simple logic circuits. Understand how

More information

PIC 10A Flow control. Ernest Ryu UCLA Mathematics

PIC 10A Flow control. Ernest Ryu UCLA Mathematics PIC 10A Flow control Ernest Ryu UCLA Mathematics If statement An if statement conditionally executes a block of code. # include < iostream > using namespace std ; int main () { double d1; cin >> d1; if

More information

Statistical Computing (36-350)

Statistical Computing (36-350) Statistical Computing (36-350) Lecture 3: Flow Control Cosma Shalizi and Vincent Vu 7 September 2011 Agenda Conditionals: Switching between doing different things Iteration: Doing similar things many times

More information

CIS 110: Introduction to Computer Programming

CIS 110: Introduction to Computer Programming CIS 110: Introduction to Computer Programming Lecture 14 Booleans and Program Assertions ( 5.3-5.5) 10/26/2011 CIS 110 (11fa) - University of Pennsylvania 1 Outline The boolean primitive type Program assertions

More information

Discrete structures - CS Fall 2017 Questions for chapter 2.1 and 2.2

Discrete structures - CS Fall 2017 Questions for chapter 2.1 and 2.2 Discrete structures - CS1802 - Fall 2017 Questions for chapter 2.1 and 2.2 1. (a) For the following switch diagrams, write the corresponding truth table and decide whether they correspond to one of the

More information

Lecture 8: Iterators and More Mutation

Lecture 8: Iterators and More Mutation Integrated Introduction to Computer Science Fisler, Nelson Contents 1 Traversing Lists 1 2 Motivating Iterators 2 3 Writing an Iterator 3 4 Writing Sum with an Iterator 4 Objectives By the end of this

More information

A QUICK INTRODUCTION TO MATLAB

A QUICK INTRODUCTION TO MATLAB A QUICK INTRODUCTION TO MATLAB Very brief intro to matlab Basic operations and a few illustrations This set is independent from rest of the class notes. Matlab will be covered in recitations and occasionally

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB --------------------------------------------------------------------------------- Getting MATLAB to Run Programming The Command Prompt Simple Expressions Variables Referencing Matrix

More information

Introduction to Engineering gii

Introduction to Engineering gii 25.108 Introduction to Engineering gii Dr. Jay Weitzen Lecture Notes I: Introduction to Matlab from Gilat Book MATLAB - Lecture # 1 Starting with MATLAB / Chapter 1 Topics Covered: 1. Introduction. 2.

More information

Iteration: Intro. Two types of loops: 1. Pretest Condition precedes body Iterates 0+ times. 2. Posttest Condition follows body Iterates 1+ times

Iteration: Intro. Two types of loops: 1. Pretest Condition precedes body Iterates 0+ times. 2. Posttest Condition follows body Iterates 1+ times Iteration: Intro Two types of loops: 1. Pretest Condition precedes body Iterates 0+ times 2. Posttest Condition follows body Iterates 1+ times 1 Iteration: While Loops Pretest loop Most general loop construct

More information

Lie, Cheat and Deceive: Change the Rules of Cyber Defense

Lie, Cheat and Deceive: Change the Rules of Cyber Defense SESSION ID: SPO-W10A Lie, Cheat and Deceive: Change the Rules of Cyber Defense Sameh Sabry Associate Vice President Professional Services Spire Solutions Why continue to do things the way we always have?

More information

1 #include <iostream > 3 using std::cout; 4 using std::cin; 5 using std::endl; 7 int main(){ 8 int x=21; 9 int y=22; 10 int z=5; 12 cout << (x/y%z+4);

1 #include <iostream > 3 using std::cout; 4 using std::cin; 5 using std::endl; 7 int main(){ 8 int x=21; 9 int y=22; 10 int z=5; 12 cout << (x/y%z+4); 2 3 using std::cout; 4 using std::cin; using std::endl; 6 7 int main(){ 8 int x=21; 9 int y=22; int z=; 11 12 cout

More information

Lecture 2 Selection and Looping. Program control, if-else, logical expressions, for loop

Lecture 2 Selection and Looping. Program control, if-else, logical expressions, for loop Lecture 2 Selection and Looping Program control, if-else, logical expressions, for loop Overview Review Program control if-else statement Relational and logical operators Logical expressions for loop statement

More information

Loop structures and booleans

Loop structures and booleans Loop structures and booleans Michael Mandel Lecture 7 Methods in Computational Linguistics I The City University of New York, Graduate Center https://github.com/ling78100/lectureexamples/blob/master/lecture07final.ipynb

More information

Short Version of Matlab Manual

Short Version of Matlab Manual Short Version of Matlab Manual This is an extract from the manual which was used in MA10126 in first year. Its purpose is to refamiliarise you with the matlab programming concepts. 1 Starting MATLAB 1.1.1.

More information

A QUICK INTRODUCTION TO MATLAB. Intro to matlab getting started

A QUICK INTRODUCTION TO MATLAB. Intro to matlab getting started A QUICK INTRODUCTION TO MATLAB Very brief intro to matlab Intro to matlab getting started Basic operations and a few illustrations This set is indepent from rest of the class notes. Matlab will be covered

More information

CSE 373: Data Structures and Algorithms

CSE 373: Data Structures and Algorithms CSE 373: Data Structures and Algorithms Lecture 17: Finish Dijkstra s Algorithm, Preserving Abstractions (Software Design), Spanning Trees Instructor: Lilian de Greef Quarter: Summer 2017 Today Wrap up

More information

Post PC Era: Mobile Banking & Payments in Emerging Markets. Report Covers: India, Kenya, Indonesia, Ghana and Nigeria

Post PC Era: Mobile Banking & Payments in Emerging Markets. Report Covers: India, Kenya, Indonesia, Ghana and Nigeria Post PC Era: Mobile Banking & Payments in Emerging Markets Report Covers: India, Kenya, Indonesia, Ghana and Nigeria In emerging markets, formal banking only reaches a small percent of the population,

More information

LSN 4 Boolean Algebra & Logic Simplification. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

LSN 4 Boolean Algebra & Logic Simplification. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology LSN 4 Boolean Algebra & Logic Simplification Department of Engineering Technology LSN 4 Key Terms Variable: a symbol used to represent a logic quantity Compliment: the inverse of a variable Literal: a

More information

Lecture. Loops && Booleans. Richard E Sarkis CSC 161: The Art of Programming

Lecture. Loops && Booleans. Richard E Sarkis CSC 161: The Art of Programming Lecture Loops && Booleans Richard E Sarkis CSC 161: The Art of Programming Class Administrivia Agenda (In-)definite loops (for/while) Patterns: interactive loop and sentinel loop Solve problems using (possibly

More information

Announcements. Homework 0: using cin with 10/3 is NOT the same as (directly)

Announcements. Homework 0: using cin with 10/3 is NOT the same as (directly) Branching Announcements Homework 0: using cin with 10/3 is NOT the same as 3.3333 (directly) With cin, it will stop as soon as it reaches a type that does not match the variable (into which it is storing)

More information

Big-step Operational Semantics (aka Natural Semantics)

Big-step Operational Semantics (aka Natural Semantics) x = 1 let x = 1 in... x(1).!x(1) x.set(1) Programming Language Theory Big-step Operational Semantics (aka Natural Semantics) Ralf Lämmel A big-step operational semantics for While 2 This slide is derived

More information

CSCI Wednesdays: 1:25-2:15 Keller Thursdays: 4:00-4:50 Akerman 211

CSCI Wednesdays: 1:25-2:15 Keller Thursdays: 4:00-4:50 Akerman 211 C++ Basics CSCI 1113 Wednesdays: 1:25-2:15 Keller 1-250 Thursdays: 4:00-4:50 Akerman 211 Peer-assisted Learning sessions - PAL Weekly practice with course concepts Work with peers to reinforce understanding

More information

Singular Value Decomposition, and Application to Recommender Systems

Singular Value Decomposition, and Application to Recommender Systems Singular Value Decomposition, and Application to Recommender Systems CSE 6363 Machine Learning Vassilis Athitsos Computer Science and Engineering Department University of Texas at Arlington 1 Recommendation

More information

Quiz Determine the output of the following program:

Quiz Determine the output of the following program: Quiz Determine the output of the following program: 1 Structured Programming Using C++ Lecture 4 : Loops & Iterations Dr. Amal Khalifa Dr. Amal Khalifa - Spring 2012 1 Lecture Contents: Loops While do-while

More information