Pemrograman komputer 4 (ekspresi)

444 views

Published on

unj fmipa-fisika

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
444
On SlideShare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Pemrograman komputer 4 (ekspresi)

  1. 1. Pemrograman Komputer Pertemuan 04 Expression Bambang Heru Iswanto, Dr.rer.nat M.Si <ul><li>Jurusan Fisika </li></ul><ul><li>Fakultas Matematika dan Ilmu Pengetahuan Alam </li></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  2. 2. Learning Outcomes <ul><li>Pada akhir pertemuan ini, diharapkan mahasiswa </li></ul><ul><li>akan mampu : </li></ul><ul><li>Menghasilkan ekspresi logikal dengan menggunakan operator perbandingan dan operator logikal </li></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  3. 3. Outline Materi <ul><li>Expression, Operator and Function </li></ul><ul><li>Arithmetic Expression </li></ul><ul><li>String Expression </li></ul><ul><li>Logical Expression </li></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  4. 4. Expressions <ul><li>An expression tells the computer to manipulate data. </li></ul><ul><li>The statement tells the computer what to do with the results of an expression. </li></ul><ul><li>Expressions are composed of values, operators, and functions. </li></ul><ul><li>Types of expressions: </li></ul><ul><ul><li>Arithmetic expressions </li></ul></ul><ul><ul><ul><li>To perform arithmetic operations. </li></ul></ul></ul><ul><ul><li>String expressions </li></ul></ul><ul><ul><ul><li>To manipulate string data. </li></ul></ul></ul><ul><ul><li>Logical expressions </li></ul></ul><ul><ul><ul><li>To select an appropriate action. </li></ul></ul></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  5. 5. Expressions <ul><li>Statements </li></ul><ul><ul><li>Perform various tasks </li></ul></ul><ul><ul><ul><li>Evaluate expressions one at a time. </li></ul></ul></ul><ul><ul><ul><li>Carry out tasks specified in expressions. </li></ul></ul></ul><ul><li>Expressions </li></ul><ul><ul><li>Single values or a combination of values, operators, and/or functions that reduce to a single value. </li></ul></ul><ul><ul><li>Evaluated by calculation or manipulation. </li></ul></ul><ul><ul><li>Result in numeric, string, or Boolean values. </li></ul></ul><ul><li>Operators </li></ul><ul><ul><li>Symbols for a common operations such as addition or multiplication. </li></ul></ul><ul><ul><li>Most operators are binary operators. </li></ul></ul><ul><li>Functions </li></ul><ul><ul><li>Descriptive names that specify a more complex operation than that performed by an operator. </li></ul></ul><ul><ul><li>Names are always followed by parentheses. </li></ul></ul><ul><ul><li>The value between the parentheses is called the argument. </li></ul></ul><ul><ul><li>The resulting value is called the return value. </li></ul></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  6. 6. Expressions <ul><li>More Complicated Expressions </li></ul><ul><ul><li>Operators and functions can be composed into complicated expressions. </li></ul></ul><ul><ul><li>A function’s argument may be complex. </li></ul></ul><ul><ul><ul><li>Ex. X = Math.Sqrt(10 + Math.Sqrt(Y + 29)) </li></ul></ul></ul><ul><li>Expressions as a Part of Statements </li></ul><ul><ul><li>An expression is always a part of a statement. </li></ul></ul><ul><ul><ul><li>Ex. Z = Math.Sqrt(X + 2 + Y) + Math.Sqrt(4) </li></ul></ul></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  7. 7. Arithmatic Expressions <ul><li>Arithmetic operators and functions must be written according to Visual Basic syntax. </li></ul><ul><li>Arithmetic Operators and Operator Precedence </li></ul><ul><ul><li>Arithmetic operations must adhere to the following order: </li></ul></ul><ul><ul><ul><li>1. Exponentiations </li></ul></ul></ul><ul><ul><ul><li>2. Unary negations </li></ul></ul></ul><ul><ul><ul><li>3. Multiplications and Divisions </li></ul></ul></ul><ul><ul><ul><li>4. Integer divisions </li></ul></ul></ul><ul><ul><ul><li>5. Modulus operations </li></ul></ul></ul><ul><ul><ul><li>6. Additions and Subtractions </li></ul></ul></ul><ul><li>Integer Division </li></ul><ul><ul><li>Calculates the number of times one integer goes into another, discarding the reminder. </li></ul></ul><ul><ul><li>Mod calculates the reminder when one integer is divided by another. </li></ul></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  8. 8. String Expressions <ul><li>Manipulate strings using string operators and functions. </li></ul><ul><ul><li>String Operators </li></ul></ul><ul><ul><ul><li>& is the only string operator in Visual Basic </li></ul></ul></ul><ul><ul><ul><li>Joining two string values is called concatenation. </li></ul></ul></ul><ul><ul><li>Functions Used with Strings </li></ul></ul><ul><ul><ul><li>Format() </li></ul></ul></ul><ul><ul><ul><ul><li>Converts a numeric value to a string and formats it. </li></ul></ul></ul></ul><ul><ul><ul><li>Left(), Right(), and Mid() </li></ul></ul></ul><ul><ul><ul><ul><li>Selects specific character(s) in a string. </li></ul></ul></ul></ul><ul><ul><ul><li>StrConv() </li></ul></ul></ul><ul><ul><ul><ul><li>Converts a string into a new string using conversion rules. </li></ul></ul></ul></ul><ul><ul><ul><li>LTrim(), Rtrim(), and Trim() </li></ul></ul></ul><ul><ul><ul><ul><li>Remove leading and trailing spaces. </li></ul></ul></ul></ul><ul><ul><ul><li>Len() </li></ul></ul></ul><ul><ul><ul><ul><li>Determines the number of characters in a string. </li></ul></ul></ul></ul><ul><ul><ul><li>Space() </li></ul></ul></ul><ul><ul><ul><ul><li>Indicates the number of spaces to create. </li></ul></ul></ul></ul><ul><ul><ul><li>InStr() </li></ul></ul></ul><ul><ul><ul><ul><li>Conducts a string search. </li></ul></ul></ul></ul><ul><ul><ul><li>Asc() and Chr() </li></ul></ul></ul><ul><ul><ul><ul><li>Access values in the ANSI table. </li></ul></ul></ul></ul><ul><ul><ul><li>Replace() </li></ul></ul></ul><ul><ul><ul><ul><li>Perform a search and replace routine. </li></ul></ul></ul></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  9. 9. Logical Expressions <ul><li>Used to select an action from alternative actions. </li></ul><ul><li>Results in a True or False answer to a test. </li></ul><ul><li>Also known as Boolean expressions. </li></ul><ul><ul><li>Comparison Operators </li></ul></ul><ul><ul><ul><li>< </li></ul></ul></ul><ul><ul><ul><li><= </li></ul></ul></ul><ul><ul><ul><li>> </li></ul></ul></ul><ul><ul><ul><li>>= </li></ul></ul></ul><ul><ul><ul><li>= </li></ul></ul></ul><ul><ul><ul><li><> </li></ul></ul></ul><ul><ul><li>Comparison of Strings </li></ul></ul><ul><ul><ul><li>Strings are ranked alphabetically. </li></ul></ul></ul><ul><ul><li>Logical Operators </li></ul></ul><ul><ul><ul><li>Combine simple logical expressions to create more complex expressions. </li></ul></ul></ul><ul><ul><ul><li>Common operators are Not, And, and Or. </li></ul></ul></ul><ul><ul><li>Logical Functions </li></ul></ul><ul><ul><ul><li>Common ones are IsNumeric() and IIf(). </li></ul></ul></ul><ul><ul><ul><li>IsNumeric() is True if the argument is a valid number. </li></ul></ul></ul><ul><ul><ul><li>IIf() chooses between two alternate paths. </li></ul></ul></ul>01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |
  10. 10. TERIMA KASIH 01/02/11 © 2010 Universitas Negeri Jakarta | www.unj.ac.id |

×