Data Types. Strings Variables Declaration Statements Named Constant Assignment Statements Intrinsic (Built-in) Functions
|
|
- Arleen Booker
- 6 years ago
- Views:
Transcription
1 Data and Operations Outline Data Types Arithmetic Operations Strings Variables Declaration Statements Named Constant Assignment Statements Intrinsic (Built-in) Functions Data and Operations 1 Data and Operations 2 Data Types In computers data such as integers, real numbers, character, strings, and Boolean are represented and stored in memory differently. In order to represent data efficiently based on memory space and calculations accuracy, the size memory space is preset for each data type to be stored. Computer languages provide appropriate different data types according to the size of storage. There are four fundamental data types: Integral types Floating-point numbers Characters String Boolean values Integral Data Types An integer type has a value as a whole number either negative or positive, e.g., 123, +123, 123, Visual Basic.NET has different integral types depends on the size of the storage. For examples, Byte -- 1 byte Short -- 2 bytes Integer -- 4 bytes Long -- 8 bytes Data and Operations 3 Data and Operations 4 1
2 Integer Data Types For values that will always be a whole number Usually name a variable starting with a 3 or 4 letter prefix indicating the variable s type Data Type Naming Prefix Description Byte byt Unsigned integer from to 255 Short shrt Signed integer from -32,768 to 32,767 Integer Long int Signed integer from -2,147,483,648 to 2,147,483,647 lng Signed integer from - 9,223,372,36,854,775,88 to 9,223,372,36,854,775,87 Floating-Point Data Types For values that may have fractional parts Single used most frequently Double sometimes used in scientific calculations Decimal often used in financial calculations Data Type Naming Prefix Description Single sng As large as 1 38 plus or minus, 7 decimal positions Double dbl As large as 1 38 plus or minus,15 decimal positions Decima l dec As large as 1 29 plus or minus, 29 decimal positions Data and Operations 5 Data and Operations 6 Floating-Point Data Types A floating number or a real number is any signed or unsigned number having an integer part and a fractional part, with a decimal point in between e.g., 18., +9.2, 35.25,.57, 138.2, 4.,.8 Visual Basic supports two different categories of floating point numbers: Single -- Numbers which are stored using the single data type are called single precision numbers. Double -- Numbers that are stored using the double data type are called double precision numbers. A double precision number uses twice the amount of storage as that used by a single precision number. Exponential Notation Exponential notation is commonly used to express both very large and very small floating point numbers in a compact form, e.g., E 12, E4, 7E2 It is similar to scientific notation. Decimal Notation Exponential Notation Scientific Notation E E E E Data and Operations 7 Data and Operations 8 2
3 Other Common Data Types Boolean variable naming prefix is bln Holds 2 possible values, True or False Char variable naming prefix is chr Holds a single character Allows for characters from other languages String variable naming prefix is str Holds a sequence of up to 2 billion characters Date variable naming prefix is dat Can hold date and/or time information Strings A string consists of one or more characters that are enclosed within double quotes. The number of characters within a string determines the length of the string. For examples, apple, S, 45, Joe Nobody and HELLO. String concatenation means the joining of two or more strings into a single string. Visual Basic provides two symbols, the ampersand (&) and the plus sign (+), for performing string concatenation. Joe & & Nobody Joe Nobody Numeric values and/or strings can be displayed using either a call to the MessageBox.Show() method or a text box. Data and Operations 9 Data and Operations 1 ASCII Code Boolean J o e A 11 N 1111 B 11 O C 111 P 11 D 11 Q 111 E 111 R 111 F 111 S 1111 G 1111 T 111 H 11 U 1111 I 111 V 1111 J 111 W K 1111 X 111 L 111 Y 1111 M 1111 Z 1111 There are only two Boolean data values in Visual Basic. These values are the constants: True and False. The Boolean constants are used in decision-making statements. Data and Operations 11 Data and Operations 12 3
4 Date Data Type Date data type variables can hold the date and time A date literal is enclosed within # symbols #1/2/25 6:3: AM# or #12/1/25# or #21:15:2# Or can use a function to convert a string to a date System.Convert.ToDateTime("12/3/22") System.Convert.ToDateTime function is used to store a date from a text box in a date variable System.Convert.ToDateTime(txtDate.text) Fundamental VB.NET Data Types Type Size in Bytes Description Byte 1 8-bit unsigned integer Range of Values Integer 4 32-bit signed integer Long 8 64-bit signed integer Short 2 16-bit signed integer 32,768-32,767 Single 4 Double 8 Decimal 16 Char 2 32-bit floating point variable 64-bit floating point variable 128-bit floating point variables 16-bit Unicode characters String Varies Non-Numeric Type E38-3.4E+38 (7 significant digits) 1.7E38-1.7E+38 (15 significant digits) - 65,535 Boolean 1 Non-Numeric Type False or True Date 8 Non-Numeric Type :: on January 1, 1 11:59:59 on December 31, 9999 Object 4 Non-Numeric Type Reference to an object Data and Operations 13 Data and Operations 14 Arithmetic Operations Visual Basic provides a number of numeric operators, which can be used to perform operations such as additions, subtractions, multiplications, etc. A simple numeric expression is an expression that has a numeric operator connecting two arithmetic operands. This type of expression has the syntax: operand operator operand A binary operator is an operator that requires two operands. A unary operator is an operator that requires only one operand. Arithmetic Operations + Unary Plus Unary Negation + Addition Subtraction * Multiplication / Division \ Integer Division ^ Mod Exponentiation Modulus -- return remainder Data and Operations 15 Data and Operations 16 4
5 Precedence of Arithmetic Operations Operator Operation ^ Exponentiation Negation * / Multiplication and Division \ Integer Division Mod Modulus -- return remainder + Addition and Subtraction Operator Precedence Examples 6 * 2^3 + 4 / 2 6 / 2 * 2^ * / 2 6 / 2 * / 2 3 * Data and Operations 17 Data and Operations 18 Rules of Forming Expressions The followings are rules when writing expressions in Visual Basic: Two binary operators must never be placed adjacent to one another. 2 * 4 is invalid. Parentheses may be used to form groupings, and all expressions enclosed within parentheses are evaluated first. Parentheses cannot be used to indicate multiplication. (1 + 2) (3) is invalid. Expression Types Integer expression -- is an arithmetic expression containing only integers. Floating point expression -- is an arithmetic expression containing only floating point numbers. Mixed-mode expression -- is an arithmetic expression containing both integers and floating point numbers. Data and Operations 19 Data and Operations 2 5
6 Types of Arithmetic Expressions combining floating point numbers with either integers or floating point numbers floating point combining integers or floating point numbers with \ integer combining integers with either +,, *,\, Mod integer Arithmetic Expression Expression Result Type Integer 11 / 4.6 *.879 Floating Point 11 / (4.6 *.879) Floating Point *.879 Floating Point Data and Operations 21 Data and Operations 22 Integer Division Operator VB.NET uses back slash (\) as integer division operator. Expression Actual Value Result 11\4 11\4 = \4.6 11\5 = \4 11\4 = \4.6 11\5 = Mod Operator The modulus operator Mod yields the remainder of the result of dividing its first operand by its second. Expression Actual Value Result 11 Mod = 2 r Mod = 5 r 11 Mod = 2 r Mod = 2 r Data and Operations 23 Data and Operations 24 6
7 Lab 5 Task 3 Statement of the Problem: Create a VB.NET application called Arithmetic Operations that a user can type in two numbers. When a user clicks on an operation button, the application will display the result of that operation operates on the two entered numbers. The design/gui of application should look similar to the following figure: Control Objects and Their Properties Control Name Text ForeColor Font Size Others Form1 Default Arithmetic Operations Default None Size: 47, 315 Textbox1 NumberBox1 None (blank) Default 12 Size: Width: 1 Textbox2 NumberBox2 None (blank) Default 12 Size: Width: 1 Size: 1, 3, Label1 DisplayLabel None (blank) Red 12 BackColor: Pale Yellow Label2 Defualt = Default 1 Size: 2, 2 Button1 AddButton + Blue 1 Size: 5, 2 Button2 SubButton Blue 1 Size: 5, 2 Button3 MulButton * Blue 1 Size: 5, 2 Button4 DivButton / Blue 1 Size: 5, 2 Button5 IDivButton \ Blue 1 Size: 5, 2 Button6 PowerButton ^ Blue 1 Size: 5, 2 Button7 ModButton Mod Blue 1 Size: 5, 2 Button8 ExitButton Exit Default 12 Size: 1, 3 Data and Operations 25 Data and Operations 26 Form Design How Many Events Are in This Project? 1. Addition (+) button click event: This event will retrieve the two numbers, perform addition, and display the result. 2. Subtraction ( ) button click event: This event will retrieve the two numbers, perform addition, and display the result. 3. Multiplication (*) button click event: This event will retrieve the two numbers, perform addition, and display the result. 4. Division (/) button click event: This event will retrieve the two numbers, perform addition, and display the result. 5. Integer division (\) button click event: This event will retrieve the two numbers, perform addition, and display the result. 6. Power (^) button click event: This event will retrieve the two numbers, perform addition, and display the result. 7. Mod button click event: This event will retrieve the two numbers, perform addition, and display the result. 8. Exit button click event: This event will retrieve the two numbers, perform addition, and display the result. 4. Division (/) button click event: 8. Exit button click event: Data and Operations 27 Data and Operations 28 7
8 Chart of Functions for Each Control Code for Each Event Procedure 1. AddButton Click Event Procedure: retrieve two numbers, perform addition, display result DisplayLabel.Text = Val(NumberBox1.Text) + Val(NumberBox2.Text) 2. AddButton Click Event Procedure: retrieve two numbers, perform addition, display result DisplayLabel.Text = Val(NumberBox1.Text) + Val(NumberBox2.Text) 3. AddButton Click Event Procedure: retrieve two numbers, perform addition, display result DisplayLabel.Text = Val(NumberBox1.Text) + Val(NumberBox2.Text) 4. AddButton Click Event Procedure: retrieve two numbers, perform addition, display result DisplayLabel.Text = Val(NumberBox1.Text) + Val(NumberBox2.Text) 5. AddButton Click Event Procedure: retrieve two numbers, perform addition, display result DisplayLabel.Text = Val(NumberBox1.Text) + Val(NumberBox2.Text) 6. AddButton Click Event Procedure: retrieve two numbers, perform addition, display result DisplayLabel.Text = Val(NumberBox1.Text) + Val(NumberBox2.Text) 7. AddButton Click Event Procedure: retrieve two numbers, perform addition, display result DisplayLabel.Text = Val(NumberBox1.Text) + Val(NumberBox2.Text) 8. ExitButton Click Event Close application/window Close() Data and Operations 29 Data and Operations 3 Variables A variable is a storage location in the computer s memory, used for holding information while the program is running. The information that is stored in a variable may change, hence the name variable. What Can You Do With Variables? Copy and store values entered by the user, so they may be manipulated Perform arithmetic on values Test values to determine that they meet some criterion Temporarily hold and manipulate the value of a control property Remember information for later use in the program Data and Operations 31 Data and Operations 32 8
9 How to Think About Variables You the programmer make up a name for the variable Visual Basic associates that name with a location in the computer's RAM The value currently associated with the variable is stored in that memory location Variable Naming Rules The first character of a variable name must be a letter or an underscore Subsequent characters may be a letter, underscore, or digit Thus variable names cannot contain spaces or periods (or many other kinds of characters) Visual Basic keywords cannot be used as variable names Data and Operations 33 Data and Operations 34 Variable Naming Conventions Naming conventions are a guideline to help improve readability but not required syntax A variable name should be chosen to indicate what it represents Each data type has a recommended prefix, in lower case, that begins the variable name The 1 st letter of each subsequent word in the variable name should be capitalized inthoursworked - an integer variable strlastname - a string (or text) variable Declaring Variables with IntelliSense As you enter your program, VB often aids you by offering a list of choices that could be used at that point After typing As in a variable declaration, VB will offer an alphabetical list of all possible data types Type the first few letters of the data type name Intellisense box will highlight the matching type Press the Tab key to select highlighted choice Or just complete typing the entire data type name Data and Operations 35 Data and Operations 36 9
10 Variable Declaration Statements A variable declaration is a statement that create a variable in memory as well as specifying the data type that can be stored in it. Declaration statements placed within a procedure and have the general syntax: Dim VariableName As DataType Dim (short for Dimension) is a keyword ariablename is the programmer designated name As is a keyword DataType is one of many possible keywords for the type of value the variable will contain Examples Dim intnumber As Integer Dim sngwages As Single Dim strlast_name As String Dim chrmiddleintial As Char Dim blnempty As Boolean Data and Operations 37 Data and Operations 38 Single-line line Declarations Visual Basic allows combining multiple declarations into one statement, using the syntax: Dim var1 As DataType, var2 As DataType,...,,...,varn As DataType Examples: Dim strfirstname As String, strlastname As data-type, strmiddleinit As Char, inttest1 As Integer, inttest2 As Integer, sngaverage As Single Dim inttest1, inttest2, inttest3, intfianlexam As Integer, sngaverage As Single Default Values When a variable is first created in memory, it is assigned a default value numeric types are given a value of zero Boolean types are given a value of False strings are given a value of Nothing dates default to 12:: AM January 1,1 Data and Operations 39 Data and Operations 4 1
11 Initialization An initialization is the process of storing a value in a variable for the first time. Declaration statements perform both a software and a hardware function. From a software perspective, declaration statements provide a convenient, up-front list of all variables and their data types. The hardware function that declaration statements perform is that they inform Visual Basic of the physical memory storage that must be reserved for each variable. Programmers use variable names to reference their contents. Initialization Can provide a starting or initialization value for any type of variable in a Dim statement Usually want to set an initial value unless assigning a value prior to using the variable Just append = value to the Dim statement where value is the literal to be assigned to the variable Dim intmonthsperyear As Integer = 12 Good practice to initialize string variables Dim strname As String = String.Empty String with value Nothing causes error if used Data and Operations 41 Data and Operations 42 Scope and Local Variables Scope refers to the part of the program where: A variable is visible and May be accessed by program code Variables declared within a procedure are called local variables and observe these characteristics Scope begins where variable is declared Extends to end of procedure where declared Variable is not visible outside the procedure A variable cannot be declared twice in the same procedure Class-Level and Global Scope A variable declared inside a class but outside any procedure is a class-level variable Scope is throughout all procedures of the class A variable declared outside any class or procedure is a global variable Scope is throughout all forms, classes, and procedures of the project Class-level and global scope will be discussed further in future chapters Values in a variable are destroyed when it goes out of scope Data and Operations 43 Data and Operations 44 11
12 Named Constants Programs often need to use given values For example: dectotal *= dectotal* 1.6 Adds 6% sales tax to an order total Two problems with this approach The reason for multiplying dectotal by 1.6 isn t always obvious If sales tax rate changes, must find and change every occurrence of.6 or 1.6 Use of named constants resolves both these issues Named Constants Constants are numbers that have a special meaning in the context of a particular application. Const statement is used to assign symbolic names to constants. The syntax for this statement within a form s procedure is: Const named-constant As DataType = expression A named constant is a symbolic name assigned to a constant. A named constant cannot be altered after it is defined. All Const statements must be placed in the Declarations section of the form or within a procedure, but for clarity they are usually placed immediately after the procedure s declaration Data and Operations 45 Data and Operations 46 Named Constants Can declare a variable whose value is set at declaration and cannot be changed later: Const sngsales_tax_rate As Single = 1.6 The objective of our code is now clearer Const sngsales_tax_rate As Single = 1.6 dectotal *= sngsales_tax_rate Examples Const bythourlyrate As Byte = 15 Const bytweekly As Byte = 4 Const sngpi As Single = Const dblsalestax As Double =.825 Data and Operations 47 Data and Operations 48 12
13 Assignment Statements Assignment statements are statements that tell the computer to store a value into a variable. An assignment statement can be used to both assign a value to a variable and to perform calculations. The assignment statement has the following syntax: variable = expression An expression is any combination of constants, variables, and operators that can be evaluated to yield a value. Assignment statements always have an equal (=) sign and exactly one variable name immediately to the left of the equal sign. The value on the right of the equal sign is assigned to the variable on the left of the equal sign. Examples Count = Count = Count + 1 Sum = Sum + Data Area = Height * Width AverageScore = TotalSum / NemberOfScores Solution = Math.Sqrt(B^2 2*A*C) Data and Operations 49 Data and Operations 5 Assignment Statements Assignment Variations Data location: Data2 49 location: Consider following actions that a computer will perform: put 65 in location put 49 in location 6789 Add the content of location to the content of location 6789 store the sum in location The programming version is as follows: Data1 = 65 Data2 = 49 Sum = Data1 + Data2 Sum location: An assignment variation statement is an assignment statement in which the variable on the left of the equal sign is also used on the right of the equal sign. For example : Total = Total Sum = Sum + Number Data and Operations 51 Data and Operations 52 13
14 Accumulating To accumulate subtotals when data is entered one number at a time, assignment statements such as Total = Total are used. These statements have the syntax: variable = variable + new value Example: SumScore = SumScore + Score Counting The counting statement is a variation of the accumulating assignment statement. It has the following form: Variable = Variable + fixed number After a counting statement is executed, the value of the variable is increased by a fixed amount. Example: Count = Count + 1 Count += 1 Data and Operations 53 Data and Operations 54 Lab 6 Task 2 Const SalesTaxRate As Single =.825 Lab 6 Task 2 Const SalesTaxRate As Single =.825 SalesTaxRate.825 Dim TotalAmount, SalesTaxAmount, InputAmount As Double Dim TotalAmount, SalesTaxAmount, InputAmount As Double REM Retrieve input amount from InputAmountTextBox and REM Compute the sales tax, then the total amount InputAmount = InputTextBox.Text SalesTaxAmount = InputAmount * SalesTaxRate TotalAmount = InputAmount + SalesTaxAmount REM Display sales tax and total amount SalesTaxLabel.Text = FormatCurrency(SalesTaxAmount) TotalAmountLabel.Text = FormatCurrency(TotalAmount) REM Retrieve input amount from InputAmountTextBox and REM Compute the sales tax, then the total amount InputAmount = InputTextBox.Text SalesTaxAmount = InputAmount * SalesTaxRate TotalAmount = InputAmount + SalesTaxAmount REM Display sales tax and total amount SalesTaxLabel.Text = FormatCurrency(SalesTaxAmount) TotalAmountLabel.Text = FormatCurrency(TotalAmount) Data and Operations 55 Data and Operations 56 14
15 Lab 6 Task 2 Lab 6 Task 2 Const SalesTaxRate As Single =.825 SalesTaxRate.825 Const SalesTaxRate As Single =.825 SalesTaxRate.825 Dim TotalAmount, SalesTaxAmount, InputAmount As Double TotalAmount. SalesTaxAmount. Dim TotalAmount, SalesTaxAmount, InputAmount As Double TotalAmount. SalesTaxAmount. REM Retrieve input amount from InputAmountTextBox and REM Compute the sales tax, then the total amount InputAmount = InputTextBox.Text SalesTaxAmount = InputAmount * SalesTaxRate TotalAmount = InputAmount + SalesTaxAmount REM Display sales tax and total amount SalesTaxLabel.Text = FormatCurrency(SalesTaxAmount) TotalAmountLabel.Text = FormatCurrency(TotalAmount) InputAmount. REM Retrieve input amount from InputAmountTextBox and REM Compute the sales tax, then the total amount InputAmount = InputTextBox.Text SalesTaxAmount = InputAmount * SalesTaxRate TotalAmount = InputAmount + SalesTaxAmount REM Display sales tax and total amount SalesTaxLabel.Text = FormatCurrency(SalesTaxAmount) TotalAmountLabel.Text = FormatCurrency(TotalAmount) InputAmount 1. Data and Operations 57 Data and Operations 58 Lab 6 Task 2 Lab 6 Task 2 Const SalesTaxRate As Single =.825 SalesTaxRate.825 Const SalesTaxRate As Single =.825 SalesTaxRate.825 Dim TotalAmount, SalesTaxAmount, InputAmount As Double TotalAmount. SalesTaxAmount 8.25 Dim TotalAmount, SalesTaxAmount, InputAmount As Double TotalAmount SalesTaxAmount 8.25 REM Retrieve input amount from InputAmountTextBox and REM Compute the sales tax, then the total amount InputAmount = InputTextBox.Text SalesTaxAmount = InputAmount * SalesTaxRate TotalAmount = InputAmount + SalesTaxAmount REM Display sales tax and total amount SalesTaxLabel.Text = FormatCurrency(SalesTaxAmount) TotalAmountLabel.Text = FormatCurrency(TotalAmount) InputAmount 1. REM Retrieve input amount from InputAmountTextBox and REM Compute the sales tax, then the total amount InputAmount = InputTextBox.Text SalesTaxAmount = InputAmount * SalesTaxRate TotalAmount = InputAmount + SalesTaxAmount REM Display sales tax and total amount SalesTaxLabel.Text = FormatCurrency(SalesTaxAmount) TotalAmountLabel.Text = FormatCurrency(TotalAmount) InputAmount 1. Data and Operations 59 Data and Operations 6 15
16 Lab 6 Task 2 Lab 6 Task 2 Const SalesTaxRate As Single =.825 SalesTaxRate.825 Const SalesTaxRate As Single =.825 SalesTaxRate.825 Dim TotalAmount, SalesTaxAmount, InputAmount As Double TotalAmount SalesTaxAmount 8.25 Dim TotalAmount, SalesTaxAmount, InputAmount As Double TotalAmount SalesTaxAmount 8.25 REM Retrieve input amount from InputAmountTextBox and REM Compute the sales tax, then the total amount InputAmount = InputTextBox.Text SalesTaxAmount = InputAmount * SalesTaxRate TotalAmount = InputAmount + SalesTaxAmount REM Display sales tax and total amount SalesTaxLabel.Text = FormatCurrency(SalesTaxAmount) TotalAmountLabel.Text = FormatCurrency(TotalAmount) InputAmount 1. REM Retrieve input amount from InputAmountTextBox and REM Compute the sales tax, then the total amount InputAmount = InputTextBox.Text SalesTaxAmount = InputAmount * SalesTaxRate TotalAmount = InputAmount + SalesTaxAmount REM Display sales tax and total amount SalesTaxLabel.Text = FormatCurrency(SalesTaxAmount) TotalAmountLabel.Text = FormatCurrency(TotalAmount) InputAmount 1. Data and Operations 61 Data and Operations 62 Implicit Type Conversions A value of one data type can be assigned to a variable of a different type An implicit type conversion is an attempt to convert to the receiving variable s data type A widening conversion suffers no loss of data Converting an integer to a single Dim sngnumber as Single = 5 A narrowing conversion may lose data Converting a decimal to an integer Dim intcount = 12.2 intcount becomes 12 Option Strict Option Strict is a VB configuration setting Only widening conversions are allowed when Option Strict is set to On An integer can be assigned to a decimal A decimal cannot be assigned to an integer A single can be assigned to a double A double cannot be assigned to a single Option Strict On is recommended to help catch errors Data and Operations 63 Data and Operations 64 16
17 Type Conversion Runtime Errors Consider the statement Dim intcount As Integer = abc123 This is a narrowing conversion With Option Strict On, statement will not compile With Option Strict Off, statement compiles but String abc123 will not convert to an integer A runtime error called a type mismatch occurs when this statement is executed Explicit Type Conversions A function performs some predetermined operation and provides a single output Input(s) Function Output VB provides a set of functions that permit narrowing conversions with Option Strict On These functions will accept a constant, variable name, or arithmetic expression The function returns the converted value Data and Operations 65 Data and Operations 66 Explicit Type Conversions The following narrowing conversions require an explicit type conversion Double to Single Single to Integer Long to Integer Boolean, Date, Object, String, and numeric types represent different sorts of values and require conversion functions as well Explicit Type Conversion Examples Rounding can be done with the CInt function intcount = CInt(12.4) intcount value is 12 intcount = CInt(12.5) intcount value is 12 CStr converts an integer value to a string Dim strtext as String = CStr(26) CDec converts a string to a decimal value Dim decpay as Decimal = CDec( $1,5 ) CDate converts a string to a date Dim dathired as Date = CDate( 5/1/25 ) Data and Operations 67 Data and Operations 68 17
18 A Full List of Conversion Functions There are conversion functions for each data type CBool ( expr ) CByte ( expr ) CChar ( expr ) CDate ( expr ) CDbl ( expr ) CDec ( expr ) CInt ( expr ) CLng ( expr ) CObj ( expr ) CShort ( expr ) CSng ( expr ) CStr ( expr ) Invalid Conversions Conversion functions can fail Dim dblsalary As Double = CDbl( xyz ) Dim dathired As Date = CDate( 5/35/25 ) String xyz can t be converted to a number There s no day 35 in the month of May These failed conversions cause a runtime error called an invalid cast exception Data and Operations 69 Data and Operations 7 The Val Function The Val function is a more forgiving means of performing string to numeric conversions Uses the form Val(string) as shown here intnumber = 45 Return value is the number 45 Argument contains the string 45 Val(InputTextBox.text) If the initial characters form a numeric value, the Val function will return that Otherwise, it will return a value of zero The Val Function Val Function Value Returned Val("34.9 ) 34.9 Val("86abc ) 86 Val("$24.95 ) Val("3,789 ) 3 Val(" ) Val("x29 ) Val("47% ) 47 Val("Geraldine ) Data and Operations 71 Data and Operations 72 18
19 Examples Function Name and Arguments Asc(string) Chr(val) CBool(expression) Description and Returned Value Convert the first character in the string to an ACII value Returns string associated with the specified ASCII value. Convert an expression to a Boolean value. Expression Dim intaverage As Integer Average = 98 / 1 Assigned Value intaverage = 1 CByte(expression) CChar(expression) CDate(expression) CDbl(expression) CDec(expression) CInt(expression) Convert an expression to a Byte with rounding if necessary. Convert the first character of a string expression to a Char Convert an expression to a date. Convert a numeric value or string expression to a Double. Convert a numeric value or string expression to a Decimal. Convert a numeric value or string expression to a Integer. Dim intnumberstring As Integer NumberString = 1 intnumberstring = 1 CLng(expression) CObj(expression) CShort(expression) Convert a numeric value or string expression to a Long. Convert an expression to an Object. Convert a numeric value or sting expression to a Short. Dim sngnumber As Single Number = 1 sngnumber = 1. CSng(expression) CStr(expression) CType(expression, type) Convert a numeric value or sting expression to a Single. Convert an expression to a String. Convert an expression to a specified type. Val(string) Return the first numeric value of the string. Data and Operations 73 Data and Operations 74 Intrinsic (Built-in) in) Functions Intrinsic functions are preprogrammed routines provided by Visual Basic.NET that can be used in a procedure. These include mathematical functions, functions to carry out conversion between data types, formatting functions, and string manipulation functions. A number of mathematical functions are found in the System.Math class of Visual Basic.NET. Functions operate in a manner similar to sub procedures, except for the fact that a function always directly returns a single value. Examples Function Name Description Returned Value Math.Sqrt(9) Square root 3 Math.Abs(-42) Absolute value 42 Math.Round(4.779, 2) Round 4.78 Math.Log(24.212) Log Data and Operations 75 Data and Operations 76 19
20 Examples Function Name Description Returned Value Val( 1 ) Convert string to value 1 CStr(1) Convert value to string 1 Int(99.8) Round to nearest integer less than or equal to the number 99 CInt(99.8) Round to nearest integer 1 Ceiling(99.8) Floor(99.8) Returns the smallest integer greater than the number Returns the integer largest less than the number 1 99 Data and Operations 77 2
Data and Operations. Outline
Data and Operations Data and Operations 1 Outline Data Types Arithmetic Operations Strings Variables Declaration Statements Named Constant Assignment Statements Intrinsic (Built-in) Functions Data and
More informationOutline. Data and Operations. Data Types. Integral Types
Outline Data and Operations Data Types Arithmetic Operations Strings Variables Declaration Statements Named Constant Assignment Statements Intrinsic (Built-in) Functions Data and Operations Data and Operations
More information3.1. Chapter. CSC 252 (MIS 385) Chapter 3 Input, Variables, Exceptions, and Calculations. Introduction. Page 1
Chapter 3 Input, Variables, Constants, And Calculations Slide 3-1 Introduction This chapter covers the use of text boxes to gather input from users It also discusses the use of variables named constants
More informationProgramming Language 2 (PL2)
Programming Language 2 (PL2) 337.1.1 - Explain rules for constructing various variable types of language 337.1.2 Identify the use of arithmetical and logical operators 337.1.3 Explain the rules of language
More informationCopyright 2014 Pearson Education, Inc. Chapter 3. Variables and Calculations. Copyright 2014 Pearson Education, Inc.
Chapter 3 Variables and Calculations Topics 3.1 Gathering Text Input 3.2 Variables and Data Types 3.3 Performing Calculations 3.4 Mixing Different Data Types 3.5 Formatting Numbers and Dates 3.6 Class-Level
More informationChapter 3. Variables and Calculations Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of
Chapter 3 Variables and Calculations Addison Wesley is an imprint of 2011 Pearson Addison-Wesley. All rights reserved. Section 3.1 GATHERING TEXT INPUT In this section, we use the TextBox control to gather
More informationUnit 4. Lesson 4.1. Managing Data. Data types. Introduction. Data type. Visual Basic 2008 Data types
Managing Data Unit 4 Managing Data Introduction Lesson 4.1 Data types We come across many types of information and data in our daily life. For example, we need to handle data such as name, address, money,
More informationReview: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements
Review: Exam 1 9/20/06 CS150 Introduction to Computer Science 1 1 Your First C++ Program 1 //*********************************************************** 2 // File name: hello.cpp 3 // Author: Shereen Khoja
More informationIntroduction to Data Entry and Data Types
212 Chapter 4 Variables and Arithmetic Operations STEP 1 With the Toolbox visible (see Figure 4-21), click the Toolbox Close button. The Toolbox closes and the work area expands in size.to reshow the Toolbox
More informationAgenda & Reading. VB.NET Programming. Data Types. COMPSCI 280 S1 Applications Programming. Programming Fundamentals
Agenda & Reading COMPSCI 80 S Applications Programming Programming Fundamentals Data s Agenda: Data s Value s Reference s Constants Literals Enumerations Conversions Implicitly Explicitly Boxing and unboxing
More informationUNIT- 3 Introduction to C++
UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage
More informationCSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York
CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this
More informationVARIABLES. 1. STRINGS Data with letters and/or characters 2. INTEGERS Numbers without decimals 3. FLOATING POINT NUMBERS Numbers with decimals
VARIABLES WHAT IS A VARIABLE? A variable is a storage location in the computer s memory, used for holding information while the program is running. The information that is stored in a variable may change,
More informationVisual C# Instructor s Manual Table of Contents
Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms
More informationMurach s Visual Basic 2012, C4 2013, Mike Murach & Associates, Inc. Slide 1. The built-in value types (continued)
The built-in value types Keyword Bytes Type Description Byte 1 Byte Positive integer value from 0 to 255 SByte 1 SByte Signed integer value from -128 to 127 Short 2 Int16 Integer from 32,768 to +32,767
More informationChapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics
Java Programming, Sixth Edition 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional Projects Additional
More informationModule 2 - Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1
Module 2 - Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1 Topics 1. Expressions 2. Operator precedence 3. Shorthand operators 4. Data/Type Conversion 1/15/19 CSE 1321 MODULE 2 2 Expressions
More informationFundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials
Fundamentals We build up instructions from three types of materials Constants Expressions Fundamentals Constants are just that, they are values that don t change as our macros are executing Fundamentals
More informationC++ Programming: From Problem Analysis to Program Design, Third Edition
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 2: Basic Elements of C++ Objectives (continued) Become familiar with the use of increment and decrement operators Examine
More informationFeatures of C. Portable Procedural / Modular Structured Language Statically typed Middle level language
1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC
More informationLanguage Fundamentals
Language Fundamentals VBA Concepts Sept. 2013 CEE 3804 Faculty Language Fundamentals 1. Statements 2. Data Types 3. Variables and Constants 4. Functions 5. Subroutines Data Types 1. Numeric Integer Long
More informationVB.NET MOCK TEST VB.NET MOCK TEST I
http://www.tutorialspoint.com VB.NET MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to VB.Net. You can download these sample mock tests at your local
More informationBASIC ELEMENTS OF A COMPUTER PROGRAM
BASIC ELEMENTS OF A COMPUTER PROGRAM CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING LOGO Contents 1 Identifier 2 3 Rules for naming and declaring data variables Basic data types 4 Arithmetic operators
More informationExpressions and Casting. Data Manipulation. Simple Program 11/5/2013
Expressions and Casting C# Programming Rob Miles Data Manipulation We know that programs use data storage (variables) to hold values and statements to process the data The statements are obeyed in sequence
More informationFull file at
Java Programming, Fifth Edition 2-1 Chapter 2 Using Data within a Program At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional
More informationChapter 2: Introduction to C++
Chapter 2: Introduction to C++ Copyright 2010 Pearson Education, Inc. Copyright Publishing as 2010 Pearson Pearson Addison-Wesley Education, Inc. Publishing as Pearson Addison-Wesley 2.1 Parts of a C++
More information! A program is a set of instructions that the. ! It must be translated. ! Variable: portion of memory that stores a value. char
Week 1 Operators, Data Types & I/O Gaddis: Chapters 1, 2, 3 CS 5301 Fall 2016 Jill Seaman Programming A program is a set of instructions that the computer follows to perform a task It must be translated
More informationExpressions and Casting
Expressions and Casting C# Programming Rob Miles Data Manipulation We know that programs use data storage (variables) to hold values and statements to process the data The statements are obeyed in sequence
More informationChapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen
Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Copyright 2009 Publishing Pearson as Pearson Education, Addison-Wesley Inc. Publishing as Pearson Addison-Wesley
More informationCSE 1001 Fundamentals of Software Development 1. Identifiers, Variables, and Data Types Dr. H. Crawford Fall 2018
CSE 1001 Fundamentals of Software Development 1 Identifiers, Variables, and Data Types Dr. H. Crawford Fall 2018 Identifiers, Variables and Data Types Reserved Words Identifiers in C Variables and Values
More informationThese are reserved words of the C language. For example int, float, if, else, for, while etc.
Tokens in C Keywords These are reserved words of the C language. For example int, float, if, else, for, while etc. Identifiers An Identifier is a sequence of letters and digits, but must start with a letter.
More informationEDIABAS BEST/2 LANGUAGE DESCRIPTION. VERSION 6b. Electronic Diagnostic Basic System EDIABAS - BEST/2 LANGUAGE DESCRIPTION
EDIABAS Electronic Diagnostic Basic System BEST/2 LANGUAGE DESCRIPTION VERSION 6b Copyright BMW AG, created by Softing AG BEST2SPC.DOC CONTENTS CONTENTS...2 1. INTRODUCTION TO BEST/2...5 2. TEXT CONVENTIONS...6
More informationChapter 2: Using Data
Chapter 2: Using Data Declaring Variables Constant Cannot be changed after a program is compiled Variable A named location in computer memory that can hold different values at different points in time
More informationBasics of Java Programming
Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement
More informationMicrosoft Visual Basic 2015: Reloaded
Microsoft Visual Basic 2015: Reloaded Sixth Edition Chapter Three Memory Locations and Calculations Objectives After studying this chapter, you should be able to: Declare variables and named constants
More informationCOMP Primitive and Class Types. Yi Hong May 14, 2015
COMP 110-001 Primitive and Class Types Yi Hong May 14, 2015 Review What are the two major parts of an object? What is the relationship between class and object? Design a simple class for Student How to
More informationReserved Words and Identifiers
1 Programming in C Reserved Words and Identifiers Reserved word Word that has a specific meaning in C Ex: int, return Identifier Word used to name and refer to a data element or object manipulated by the
More informationExpressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationBits, Words, and Integers
Computer Science 52 Bits, Words, and Integers Spring Semester, 2017 In this document, we look at how bits are organized into meaningful data. In particular, we will see the details of how integers are
More informationDEPARTMENT OF MATHS, MJ COLLEGE
T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,
More informationDeclaration and Memory
Declaration and Memory With the declaration int width; the compiler will set aside a 4-byte (32-bit) block of memory (see right) The compiler has a symbol table, which will have an entry such as Identifier
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More informationData and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence
Data and Variables Data Types Expressions Operators Precedence String Concatenation Variables Declaration Assignment Shorthand operators Review class All code in a java file is written in a class public
More informationJava Notes. 10th ICSE. Saravanan Ganesh
Java Notes 10th ICSE Saravanan Ganesh 13 Java Character Set Character set is a set of valid characters that a language can recognise A character represents any letter, digit or any other sign Java uses
More informationThe C++ Language. Arizona State University 1
The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University
More informationDepartment of Computer and Mathematical Sciences. Lab 7: Selection
Unit 2: Visual Basic.NET, pages 1 of 11 Department of Computer and Mathematical Sciences CS 1408 Intro to Computer Science with Visual Basic.NET 7 Lab 7: Selection Objectives: The main objective of this
More informationOn a 64-bit CPU. Size/Range vary by CPU model and Word size.
On a 64-bit CPU. Size/Range vary by CPU model and Word size. unsigned short x; //range 0 to 65553 signed short x; //range ± 32767 short x; //assumed signed There are (usually) no unsigned floats or doubles.
More informationExpressions and Data Types CSC 121 Fall 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and
More information2. A GUI A. uses buttons, menus, and icons B. should be easy for a user to manipulate C. both (a) and (b) D. stands for Graphic Use Interaction
1. Which language is not a true object-oriented programming language? A. VB 6 B. VB.NET C. JAVA D. C++ 2. A GUI A. uses buttons, menus, and icons B. should be easy for a user to manipulate C. both (a)
More informationMicrosoft Visual Basic 2005: Reloaded
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations Objectives After studying this chapter, you should be able to: Declare variables and named
More informationJava Programming Fundamentals. Visit for more.
Chapter 4: Java Programming Fundamentals Informatics Practices Class XI (CBSE Board) Revised as per CBSE Curriculum 2015 Visit www.ip4you.blogspot.com for more. Authored By:- Rajesh Kumar Mishra, PGT (Comp.Sc.)
More informationObjectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program
Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationVB FUNCTIONS AND OPERATORS
VB FUNCTIONS AND OPERATORS In der to compute inputs from users and generate results, we need to use various mathematical operats. In Visual Basic, other than the addition (+) and subtraction (-), the symbols
More informationChapter 2: Basic Elements of C++
Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationLanguage Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */
Overview Language Basics This chapter describes the basic elements of Rexx. It discusses the simple components that make up the language. These include script structure, elements of the language, operators,
More informationChapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction
Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers
More informationLesson 02 Working with Data Types MIT 31043, Visual Programming By: S. Sabraz Nawaz
Lesson 02 Working with Data Types MIT 31043, Visual Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT Faculty of Management and Commerce South Eastern University of Sri Lanka Variables
More informationObjectives. In this chapter, you will:
Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates arithmetic expressions Learn about
More informationLecture 2 Tao Wang 1
Lecture 2 Tao Wang 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common programming errors
More informationProgramming and Data Structures
Programming and Data Structures Teacher: Sudeshna Sarkar sudeshna@cse.iitkgp.ernet.in Department of Computer Science and Engineering Indian Institute of Technology Kharagpur #include int main()
More informationJAVA Programming Fundamentals
Chapter 4 JAVA Programming Fundamentals By: Deepak Bhinde PGT Comp.Sc. JAVA character set Character set is a set of valid characters that a language can recognize. It may be any letter, digit or any symbol
More informationComputer System and programming in C
1 Basic Data Types Integral Types Integers are stored in various sizes. They can be signed or unsigned. Example Suppose an integer is represented by a byte (8 bits). Leftmost bit is sign bit. If the sign
More information2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program
Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Parts of a C++ Program Parts of a C++ Program // sample C++ program
More informationFundamental of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering
More informationInformation Science 1
Topics covered Information Science 1 Terms and concepts from Week 8 Simple calculations Documenting programs Simple Calcula,ons Expressions Arithmetic operators and arithmetic operator precedence Mixed-type
More informationInformation Science 1
Information Science 1 Simple Calcula,ons Week 09 College of Information Science and Engineering Ritsumeikan University Topics covered l Terms and concepts from Week 8 l Simple calculations Documenting
More informationVARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.
Lesson 2 VARIABLES Aim Understanding how computer programs store values, and how they are accessed and used in computer programs. WHAT ARE VARIABLES? When you input data (i.e. information) into a computer
More informationLESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:
LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words
More informationIntroduction to Computer Use II
Winter 2005 (Section M) Topic B: Variables, Data Types and Expressions Wednesday, January 18 2006 COSC 1530, Winter 2006, Overview (1): Before We Begin Some administrative details Some questions to consider
More informationFundamentals of Programming
Fundamentals of Programming Lecture 3 - Constants, Variables, Data Types, And Operations Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline C Program Data types Variables
More informationLECTURE 3 C++ Basics Part 2
LECTURE 3 C++ Basics Part 2 OVERVIEW Operators Type Conversions OPERATORS Operators are special built-in symbols that have functionality, and work on operands. Operators are actually functions that use
More informationOperators. Lecture 3 COP 3014 Spring January 16, 2018
Operators Lecture 3 COP 3014 Spring 2018 January 16, 2018 Operators Special built-in symbols that have functionality, and work on operands operand an input to an operator Arity - how many operands an operator
More informationCS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University
CS5000: Foundations of Programming Mingon Kang, PhD Computer Science, Kennesaw State University Overview of Source Code Components Comments Library declaration Classes Functions Variables Comments Can
More informationThe PCAT Programming Language Reference Manual
The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT language
More informationExpressions and Data Types CSC 121 Spring 2017 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2017 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationObject Oriented Programming with Visual Basic.Net
Object Oriented Programming with Visual Basic.Net By: Dr. Hossein Hakimzadeh Computer Science and Informatics IU South Bend (c) Copyright 2007 to 2015 H. Hakimzadeh 1 What do we need to learn in order
More informationLesson 02 Working with Data Types. MIT 31043: VISUAL PROGRAMMING By: S. Sabraz Nawaz Senior Lecturer in MIT
Lesson 02 Working with Data Types MIT 31043: VISUAL PROGRAMMING Senior Lecturer in MIT Variables A variable is a storage location in memory that is represented by a name. A variable stores data, which
More informationLESSON 5 FUNDAMENTAL DATA TYPES. char short int long unsigned char unsigned short unsigned unsigned long
LESSON 5 ARITHMETIC DATA PROCESSING The arithmetic data types are the fundamental data types of the C language. They are called "arithmetic" because operations such as addition and multiplication can be
More informationLECTURE 02 INTRODUCTION TO C++
PowerPoint Slides adapted from *Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* Copyright 2012 Pearson Education Inc. COMPUTER PROGRAMMING LECTURE 02 INTRODUCTION
More informationEx: If you use a program to record sales, you will want to remember data:
Data Variables Programs need to remember values. Ex: If you use a program to record sales, you will want to remember data: A loaf of bread was sold to Sione Latu on 14/02/19 for T$1.00. Customer Name:
More informationCOMP1730/COMP6730 Programming for Scientists. Data: Values, types and expressions.
COMP1730/COMP6730 Programming for Scientists Data: Values, types and expressions. Lecture outline * Data and data types. * Expressions: computing values. * Variables: remembering values. What is data?
More informationChapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 2 : C# Language Basics Lecture Contents 2 The C# language First program Variables and constants Input/output Expressions and casting
More informationLecture 1. Types, Expressions, & Variables
Lecture 1 Types, Expressions, & Variables About Your Instructor Director: GDIAC Game Design Initiative at Cornell Teach game design (and CS 1110 in fall) 8/29/13 Overview, Types & Expressions 2 Helping
More informationProgramming in C++ 5. Integral data types
Programming in C++ 5. Integral data types! Introduction! Type int! Integer multiplication & division! Increment & decrement operators! Associativity & precedence of operators! Some common operators! Long
More informationThe SPL Programming Language Reference Manual
The SPL Programming Language Reference Manual Leonidas Fegaras University of Texas at Arlington Arlington, TX 76019 fegaras@cse.uta.edu February 27, 2018 1 Introduction The SPL language is a Small Programming
More information4. Inputting data or messages to a function is called passing data to the function.
Test Bank for A First Book of ANSI C 4th Edition by Bronson Link full download test bank: http://testbankcollection.com/download/test-bank-for-a-first-book-of-ansi-c-4th-edition -by-bronson/ Link full
More informationProgramming in C++ 6. Floating point data types
Programming in C++ 6. Floating point data types! Introduction! Type double! Type float! Changing types! Type promotion & conversion! Casts! Initialization! Assignment operators! Summary 1 Introduction
More informationChapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1
Chapter 2 Input, Processing, and Output Fall 2016, CSUS Designing a Program Chapter 2.1 1 Algorithms They are the logic on how to do something how to compute the value of Pi how to delete a file how to
More informationPrimitive Data Types: Intro
Primitive Data Types: Intro Primitive data types represent single values and are built into a language Java primitive numeric data types: 1. Integral types (a) byte (b) int (c) short (d) long 2. Real types
More informationChapter 17. Fundamental Concepts Expressed in JavaScript
Chapter 17 Fundamental Concepts Expressed in JavaScript Learning Objectives Tell the difference between name, value, and variable List three basic data types and the rules for specifying them in a program
More information9/21/17. Outline. Expression Evaluation and Control Flow. Arithmetic Expressions. Operators. Operators. Notation & Placement
Outline Expression Evaluation and Control Flow In Text: Chapter 6 Notation Operator evaluation order Operand evaluation order Overloaded operators Type conversions Short-circuit evaluation of conditions
More informationGetting started with Java
Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving
More informationWill introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators
Operators Overview Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators Operands and Operators Mathematical or logical relationships
More informationBasic Operations jgrasp debugger Writing Programs & Checkstyle
Basic Operations jgrasp debugger Writing Programs & Checkstyle Suppose you wanted to write a computer game to play "Rock, Paper, Scissors". How many combinations are there? Is there a tricky way to represent
More informationCIS 3260 Intro to Programming with C#
Variables, Constants and Calculations McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Define a variable Distinguish between variables, constants, and control objects Differentiate
More informationWork relative to other classes
Work relative to other classes 1 Hours/week on projects 2 C BOOTCAMP DAY 1 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh Overview C: A language
More informationCHAPTER 3 Expressions, Functions, Output
CHAPTER 3 Expressions, Functions, Output More Data Types: Integral Number Types short, long, int (all represent integer values with no fractional part). Computer Representation of integer numbers - Number
More informationIntroduction to Visual Basic and Visual C++ Arithmetic Expression. Arithmetic Expression. Using Arithmetic Expression. Lesson 4.
Introduction to Visual Basic and Visual C++ Arithmetic Expression Lesson 4 Calculation I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Arithmetic Expression Using Arithmetic Expression Calculations
More informationMATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards
MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards Language Reference Manual Introduction The purpose of
More information