Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Chapter 2: Data Types & Operations Part 3 ICS101: Computer Programming Al-Hashim, Amin G.

Similar presentations


Presentation on theme: "1 Chapter 2: Data Types & Operations Part 3 ICS101: Computer Programming Al-Hashim, Amin G."— Presentation transcript:

1 1 Chapter 2: Data Types & Operations Part 3 ICS101: Computer Programming Al-Hashim, Amin G.

2 2 Outline  Logical Operations  Relational Operations  Logical Expressions  Assignment Statement  Simple Input Statement  Simple Output Statement  Home Assignment

3 3 Logical Operations  Evaluated to either.TRUE. or.FALSE.  Logical Operators: .NOT. .AND. .OR.  E.g.: .FALSE..OR..NOT..TRUE..AND..TRUE. ORDER OF EVALUATION

4 4 Relational Operations  Evaluated to either.TRUE. or.FALSE.  Can be used to compare the values of arithmetic expressions  Relational Operators: .EQ. .NE. .GT. .GE. .LT. .LE.  Order of evaluation:  E.g.:  NUM1.LE. NUM2 Left to right

5 5 Logical Expressions  Evaluated to either.TRUE. or.FALSE.  May contain:  arithmetic expressions,  relational operations, and  logical operations  E.g.: (Evaluate)  Assume X=3.0, Y=5.0, Z=10.0, FLAG=.FALSE..NOT. FLAG.AND. X*Y.GT. Z.OR. X+Y.GT. Z ORDER OF EVALUATION

6 6 Assignment Statement  Assigns a value to a variable  General Form: variable = expression  Expression value must be the same type as the variable Exception: – A real value can be assigned to integer variable – An integer value can be assigned to real variable  E.g.: (What are the values of M, N, A, & B?)  INTEGER M, N REAL A, B A = 6.2 B = A + 9/2 M = B N = B + 1.6 A = N A = M + N N = A + B M = N + 3**3.0

7 7 Simple Input Statement  Reads a value from the terminal to a variable  Form: READ*, list of variable separated by commas  Each reading statement starts reading from a new line  If the input data is very long that can’t fit to 1 line, reading will continue to the next line  Data values can be separated by blanks or commas  Data values must agree with the variable types Exception: – Integer values can be read to real variables  Extra data on input line is ignored

8 8 Simple Output Statement  Prints the values of variables, expression, or constant to the terminal  Form: PRINT*, list of variables, expressions, or constants separated by commas  Each statement print on a new line  If the line is not enough, printing continue on the next line  If a variable w/o a value, it will produce ?s when printed

9 9 Home Assignment  Practice solving the exercises at the end of chapter 2 and if you have any difficulty, raise it in the next class  Remember to bring your textbook for the next class


Download ppt "1 Chapter 2: Data Types & Operations Part 3 ICS101: Computer Programming Al-Hashim, Amin G."

Similar presentations


Ads by Google