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

Pemrograman komputer 4 (ekspresi)

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