Conditional Statements - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Conditional Statements

Description:

Description. Operator. 4. Relational Operators. The comparison result is either '0' if false ' ... OR. S || T. Logical OR. Example. Description. Operator ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 9
Provided by: ANAN54
Category:

less

Transcript and Presenter's Notes

Title: Conditional Statements


1
Conditional Statements
  • ??.??.?????? ???????
  • Anan Phonphoem
  • http//www.cpe.ku.ac.th/anan
  • anan_at_cpe.ku.ac.th

2
Overview
  • Relational operators
  • Logical operators
  • Condition Statements

3
Relational Operators
Operator Description Example
Equal S T
Not Equal S T
lt Less than S lt T
gt Greater than S gt T
lt Less than or equal S lt T
gt Greater than or equal S gt T
4
Relational Operators
  • The comparison result is either
  • 0 if false
  • 1 if true
  • Normally is Array comparison
  • Can be used for Array addressing

5
Array comparison
gtgtc (a b) c 0 0 1 0
gtgta 1 2 3 4 gtgtb -1 4 3 0
gtgtc (a lt b)
gtgtc (a b) c 1 1 0 1
c 0 1 0 0
gtgtc (a b)
gtgtc (a gt b) c 1 0 1 1
??? c (a b) Error The
expression
6
Array addressing
gtgta 1 2 3 4 gtgtb -1 4 3 0
gtgtc a(a lt b)
gtgtc b(a b) c 3
c 2
gtgtc a(a b)
gtgtc b(a gt b) c -1 3 0
c 1 2 4
7
More on comparison
gtgt 3 lt 5 ans 1
gtgta 04 a 0 1 2 3 4 gtgtx (sqrt(a)gt1) x
0 1 1 1 1 gtgty a(x) y 1 2 3 4
gtgt a (12 lt 7) a 0
8
Logical Operators
Operator Description Example
Logical AND S T
Logical OR S T
Element-wise logical AND S T
Element-wise logical OR S T
Logical NOT S
Write a Comment
User Comments (0)
About PowerShow.com