Microsoft Visual Basic 2005: Reloaded
|
|
- Susanna Cummings
- 5 years ago
- Views:
Transcription
1 Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations
2 Objectives After studying this chapter, you should be able to: Declare variables and named constants Assign data to an existing variable Convert data to the appropriate type using the TryParse method and the Convert class methods Write arithmetic expressions Understand the scope and lifetime of variables and named constants Microsoft Visual Basic 2005: Reloaded, Second Edition 2
3 Objectives (continued) Understand the purpose of the Option Explicit, Option Strict, and Imports statements Use a TOE chart, pseudocode, and a flowchart to code an application Clear the contents of a control s Text property while an application is running Microsoft Visual Basic 2005: Reloaded, Second Edition 3
4 Objectives (continued) Send the focus to a control while the application is running Explain the difference between syntax errors and logic errors Format an application s numeric output Microsoft Visual Basic 2005: Reloaded, Second Edition 4
5 Variables Variables: computer memory locations used to store data while an application is running Every variable has a: Name Data type Scope Lifetime Microsoft Visual Basic 2005: Reloaded, Second Edition 5
6 Selecting a Data Type for a Variable Each variable must be assigned a data type Data type: the type of data the variable can store Each data type is a class Unicode: Universal coding scheme for characters Assigns a unique numeric value to each character Microsoft Visual Basic 2005: Reloaded, Second Edition 6
7 Selecting a Data Type for a Variable (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 7
8 Selecting a Name for a Variable Identifier: descriptive name given to a variable Use a meaningful name that reflects the purpose of the variable Use camel casing for variable identifiers Variable names must conform to naming rules Microsoft Visual Basic 2005: Reloaded, Second Edition 8
9 Selecting a Name for a Variable (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 9
10 Declaring a Variable Declaration statement: used to declare, or create, a variable Declaration statement includes Scope keyword: Dim or Private or Static Name of the variable Data type Initial value (optional) Microsoft Visual Basic 2005: Reloaded, Second Edition 10
11 Declaring a Variable (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 11
12 Assigning Data to an Existing Variable Assignment statement: Used to assign values to properties of controls Used to assign values to variables Assignment operator: (=) Value on the right of the = operator is assigned to the variable on the left of the = operator Microsoft Visual Basic 2005: Reloaded, Second Edition 12
13 Assigning Data to an Existing Variable (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 13
14 Assigning Data to an Existing Variable (continued) String: group of characters enclosed in quotation marks Literal constant: An item of data whose value does not change while the application is running Can be a numeric or a string literal constant A numeric literal with a decimal place is treated as a Double type Literal type character: forces a literal constant to assume a specific data type Microsoft Visual Basic 2005: Reloaded, Second Edition 14
15 Assigning Data to an Existing Variable (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 15
16 Using the TryParse Method Method: a specific portion of a class s instructions that performs a task for the class TryParse method: Part of every numeric data type s class Used to convert a string to that numeric data type TryParse method has 4 arguments String: string value to be converted Variable: location to store the result IFormatProvider (optional): specifies formatting NumberStyles (optional): allows formatting characters to be in the data to be converted Microsoft Visual Basic 2005: Reloaded, Second Edition 16
17 Using the TryParse Method (continued) IFormatProvider argument formats numbers, dates, and times NumberFormatInfo.CurrentInfo value: Uses the formatting characters specified in the Windows Customize Regional Options dialog box Microsoft Visual Basic 2005: Reloaded, Second Edition 17
18 Using the TryParse Method (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 18
19 Using the TryParse Method (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 19
20 Using the TryParse Method (continued) Assign the TryParse method s return value to a Boolean variable If True, the conversion was successful If False, the value could not be converted Line continuation character: the underscore (_) Breaks up a long instruction into two or more lines Must appear at end of line, preceded by a space Must have an Imports statement in the General Declarations section of code to use NumberStyles and NumberformatInfo.CurrentInfo: Imports System.Globalization Microsoft Visual Basic 2005: Reloaded, Second Edition 20
21 Using the TryParse Method (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 21
22 Convert class: Using the Convert Class Contains methods for converting numeric values to specific data types Use the dot member access operator to separate the class name from the method name Microsoft Visual Basic 2005: Reloaded, Second Edition 22
23 Using the Convert Class (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 23
24 Writing Arithmetic Expressions Precedence number: indicates the order in which an operation in an expression is performed If an expression has two operators with the same precedence, they are evaluated from left to right Use parentheses to change the order of evaluation Integer division operator (\): divides two integers and returns an integer value Modulus arithmetic operator (Mod): divides two numbers and returns the remainder Microsoft Visual Basic 2005: Reloaded, Second Edition 24
25 Writing Arithmetic Expressions (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 25
26 Writing Arithmetic Expressions (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 26
27 The Scope and Lifetime of a Variable Scope: indicates where the variable can be used Lifetime: indicates how long the variable remains in memory Variables are usually declared in two places: Within a procedure In the form s Declarations section Procedure-level variable: declared within a procedure Procedure scope: only the procedure can use the variable Microsoft Visual Basic 2005: Reloaded, Second Edition 27
28 The Scope and Lifetime of a Variable (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 28
29 The Scope and Lifetime of a Variable (continued) With procedure-level scope, two procedures can each use the same variable names Comments: Used to internally document the procedure Are ignored by the compiler Appear in green in the code editor Microsoft Visual Basic 2005: Reloaded, Second Edition 29
30 The Scope and Lifetime of a Variable (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 30
31 The Scope and Lifetime of a Variable (continued) Module scope: variable can be used by all procedures in the form Module-level variable: Declared in the form s Declarations section Use Private keyword in declaration Module-level variables retain their values until the application ends Microsoft Visual Basic 2005: Reloaded, Second Edition 31
32 The Scope and Lifetime of a Variable (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 32
33 The Scope and Lifetime of a Variable (continued) Block scope: variable can be used within a specific block of code Block-level variable: declared within a specific block of code Microsoft Visual Basic 2005: Reloaded, Second Edition 33
34 Static Variables Static variable: Procedure-level variable that retains its value even after the procedure ends Retains its value until the application ends Can be used instead of a module-level variable A static variable has: Same lifetime as a module-level variable Narrower scope than a module-level variable Declared using the Static keyword Microsoft Visual Basic 2005: Reloaded, Second Edition 34
35 Static Variables (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 35
36 Named Constants Named constant: memory location whose value cannot be changed while the application is running Declared using the Const keyword Good programming practice to specify the data type as well Microsoft Visual Basic 2005: Reloaded, Second Edition 36
37 Named Constants (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 37
38 Named Constants (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 38
39 Named Constants (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 39
40 Option Explicit and Option Strict Option Explicit: When on, all variables used must first be declared Protects against misspelled variable names in code Placed in the General Declarations section of code editor Implicit type conversion: can occur if the value on the right side of an assignment statement is not the same data type as the variable on the left side Microsoft Visual Basic 2005: Reloaded, Second Edition 40
41 Option Explicit and Option Strict (continued) Promoting: when a value is converted to another data type that stores larger numbers Demoting: when a value is converted to another data type that stores only smaller numbers Data loss can occur with demoting Option Strict: Can be used to enforce correct data typing Placed in the General Declarations section of the code editor Microsoft Visual Basic 2005: Reloaded, Second Edition 41
42 Option Explicit and Option Strict (continued) Option Strict On follows these conversion rules: Strings are not implicitly converted to numbers or vice versa Narrower data types are implicitly promoted to wider data types Wider data types are not implicitly demoted to narrower data types Microsoft Visual Basic 2005: Reloaded, Second Edition 42
43 Option Explicit and Option Strict (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 43
44 Coding the Skate-Away Sales Application Microsoft Visual Basic 2005: Reloaded, Second Edition 44
45 Coding the Skate-Away Sales Application (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 45
46 Using Pseudocode to Plan a Procedure Pseudocode: short phrases to describe the steps a procedure needs to take to accomplish its goal Microsoft Visual Basic 2005: Reloaded, Second Edition 46
47 Using Pseudocode to Plan a Procedure (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 47
48 Using a Flowchart to Plan a Procedure Flowchart: uses standardized symbols to show the steps a procedure must take to accomplish its goal Can be used in place of pseudocode for planning Three symbols: Start/stop symbol (oval): indicates start and stop points Process symbol (rectangle): represents tasks Input/output symbol (parallelogram): represents input or output tasks Microsoft Visual Basic 2005: Reloaded, Second Edition 48
49 Using a Flowchart to Plan a Procedure (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 49
50 Using a Flowchart to Plan a Procedure (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 50
51 Coding the clearbutton s Click Event Procedure Microsoft Visual Basic 2005: Reloaded, Second Edition 51
52 Clearing the Contents of a Control s Text Property Microsoft Visual Basic 2005: Reloaded, Second Edition 52
53 Clearing the Contents of a Control s Text Property (continued) Zero-length string (or empty string): Removes the contents in the Text property of a control Use empty set of quotation marks: String.Empty: used to assign an empty string to a control s Text property For TextBox control, use the Clear method Microsoft Visual Basic 2005: Reloaded, Second Edition 53
54 Setting the Focus Focus method: moves the focus to a specified control at runtime Microsoft Visual Basic 2005: Reloaded, Second Edition 54
55 Setting the Focus (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 55
56 Setting the Focus (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 56
57 Coding the calcbutton s Click Event Procedure Microsoft Visual Basic 2005: Reloaded, Second Edition 57
58 Coding the calcbutton s Click Event Procedure (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 58
59 Coding the calcbutton s Click Event Procedure (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 59
60 Testing and Debugging the Application Valid data: data that the application is expecting Invalid data: data that is unexpected Debugging: locating errors in a program Syntax errors: usually caused by mistyping Logic errors: occur when you enter an instruction that does not give the expected results Test a program with both valid and invalid data Microsoft Visual Basic 2005: Reloaded, Second Edition 60
61 Testing and Debugging the Application (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 61
62 Testing and Debugging the Application (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 62
63 Formatting Numeric Output Formatting: specifying the number of decimal places and any special characters to display Format specifier: specifies the type of formatting to use Precision specifier: controls the number of significant digits or zeros to the right of the decimal point Microsoft Visual Basic 2005: Reloaded, Second Edition 63
64 Formatting Numeric Output (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 64
65 Formatting Numeric Output (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 65
66 Formatting Numeric Output (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 66
67 Formatting Numeric Output (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 67
68 Formatting Numeric Output (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 68
69 Programming Tutorial Microsoft Visual Basic 2005: Reloaded, Second Edition 69
70 Programming Example Microsoft Visual Basic 2005: Reloaded, Second Edition 70
71 Summary Variables and named constants are memory locations that store data Variables can change value, but constants cannot Variables and constants have a name, data type, scope, and lifetime Use Dim to declare a variable at block or procedure level Use Private to declare a variable at module level Microsoft Visual Basic 2005: Reloaded, Second Edition 71
72 Summary (continued) Assignment statement is used to assign values to an existing variable Literals are constant items of data Use the TryParse method to convert a string to a number Use the Imports statement to import a namespace The Convert class contains methods to convert values to a specified data type Microsoft Visual Basic 2005: Reloaded, Second Edition 72
73 Summary (continued) A procedure-level variable is usable only by the procedure in which it is declared A module-level variable is usable by all procedures in the form A block-level variable is usable only within the block in which it is declared A static variable is a procedure-level variable that retains its value when the procedure ends Option Explicit On forces declaration of all variables before use Microsoft Visual Basic 2005: Reloaded, Second Edition 73
74 Summary (continued) Option Strict On disallows any implicit type conversions that may cause a loss of data Pseudocode or a flowchart is used to plan a procedure s code Use the Clear method or empty string to clear a textbox The Focus method moves the focus to a control Test a program with both valid and invalid data Microsoft Visual Basic 2005: Reloaded, Second Edition 74
SKILL AREA 306: DEVELOP AND IMPLEMENT COMPUTER PROGRAMS
Add your company slogan SKILL AREA 306: DEVELOP AND IMPLEMENT COMPUTER PROGRAMS Computer Programming (YPG) LOGO 306.1 Review Selected Programming Environment 306.1.1 Explain the concept of reserve words,
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 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 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 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 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 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 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 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 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 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 informationProgramming Logic and Design Seventh Edition Chapter 2 Elements of High-Quality Programs
Programming Logic and Design Chapter 2 Elements of High-Quality Programs Objectives In this chapter, you will learn about: Declaring and using variables and constants Assigning values to variables [assignment
More informationJava Primer 1: Types, Classes and Operators
Java Primer 1 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Java Primer 1: Types,
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: 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 informationX Language Definition
X Language Definition David May: November 1, 2016 The X Language X is a simple sequential programming language. It is easy to compile and an X compiler written in X is available to simplify porting between
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 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 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 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 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 informationFRAC: Language Reference Manual
FRAC: Language Reference Manual Justin Chiang jc4127 Kunal Kamath kak2211 Calvin Li ctl2124 Anne Zhang az2350 1. Introduction FRAC is a domain-specific programming language that enables the programmer
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 informationBoredGames Language Reference Manual A Language for Board Games. Brandon Kessler (bpk2107) and Kristen Wise (kew2132)
BoredGames Language Reference Manual A Language for Board Games Brandon Kessler (bpk2107) and Kristen Wise (kew2132) 1 Table of Contents 1. Introduction... 4 2. Lexical Conventions... 4 2.A Comments...
More information4. The is a diagram that graphically depicts the steps that take place in a program. a. Program b. Flowchart c. Algorithm d. Code e.
Gaddis: Starting Out with Programming Logic & Design Test Bank Chapter Two MULTIPLE CHOICE 1. Which error produces incorrect results but does not prevent the program from running? a. syntax b. logic c.
More informationVisual BASIC Creating an Application. Choose File New Project from the menu
Creating an Application Choose File New Project from the menu Choose Windows Application Name the project Copyright Project Place a check in the Create directory for solution box Click Browse Choose and/or
More informationBy the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program
1 By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program variables. Apply C++ syntax rules to declare variables, initialize
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationCSE 123 Introduction to Computing
CSE 123 Introduction to Computing Lecture 6 Programming with VBA (Projects, forms, modules, variables, flowcharts) SPRING 2012 Assist. Prof. A. Evren Tugtas Starting with the VBA Editor Developer/Code/Visual
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 informationIntroduction to C# Applications
1 2 3 Introduction to C# Applications OBJECTIVES To write simple C# applications To write statements that input and output data to the screen. To declare and use data of various types. To write decision-making
More informationTypescript on LLVM Language Reference Manual
Typescript on LLVM Language Reference Manual Ratheet Pandya UNI: rp2707 COMS 4115 H01 (CVN) 1. Introduction 2. Lexical Conventions 2.1 Tokens 2.2 Comments 2.3 Identifiers 2.4 Reserved Keywords 2.5 String
More informationProgramming Logic and Design Sixth Edition Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs
Objectives Programming Logic and Design Sixth Edition Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs In this chapter, you will learn about: Declaring and using variables
More informationIT 374 C# and Applications/ IT695 C# Data Structures
IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation
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 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 informationc) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.
2.1 Introduction (No questions.) 2.2 A Simple Program: Printing a Line of Text 2.1 Which of the following must every C program have? (a) main (b) #include (c) /* (d) 2.2 Every statement in C
More informationBit (0, 1) Byte (8 bits: 0-255) Numeral systems. Binary (bin) 0,1 Decimal (dec) 0, 1, 2, 3, Hexadecimal (hex) 0, 1, 2, 3, 1/13/2011
* VB.NET Syntax I 1. Elements of code 2. Declaration and statements 3. Naming convention 4. Types and user defined types 5. Enumerations and variables Bit (0, 1) Byte (8 bits: 0-255) Numeral systems Binary
More informationChapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. A Guide to this Instructor s Manual:
Java Programming, Eighth Edition 2-1 Chapter 2 Using Data A Guide to this Instructor s Manual: We have designed this Instructor s Manual to supplement and enhance your teaching experience through classroom
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 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 informationLecture 3 Tao Wang 1
Lecture 3 Tao Wang 1 Objectives In this chapter, you will learn about: Arithmetic operations Variables and declaration statements Program input using the cin object Common programming errors C++ for Engineers
More informationegrapher Language Reference Manual
egrapher Language Reference Manual Long Long: ll3078@columbia.edu Xinli Jia: xj2191@columbia.edu Jiefu Ying: jy2799@columbia.edu Linnan Wang: lw2645@columbia.edu Darren Chen: dsc2155@columbia.edu 1. Introduction
More informationObjectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments
Basics Objectives Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments 2 Class Keyword class used to define new type specify
More informationARG! Language Reference Manual
ARG! Language Reference Manual Ryan Eagan, Mike Goldin, River Keefer, Shivangi Saxena 1. Introduction ARG is a language to be used to make programming a less frustrating experience. It is similar to C
More informationChapter 2: Using Data
Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that
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 informationJava How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.
Java How to Program, 10/e Education, Inc. All Rights Reserved. Each class you create becomes a new type that can be used to declare variables and create objects. You can declare new classes as needed;
More informationCSC Web Programming. Introduction to JavaScript
CSC 242 - Web Programming Introduction to JavaScript JavaScript JavaScript is a client-side scripting language the code is executed by the web browser JavaScript is an embedded language it relies on its
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 informationExpr Language Reference
Expr Language Reference Expr language defines expressions, which are evaluated in the context of an item in some structure. This article describes the syntax of the language and the rules that govern the
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 informationData Types. Strings Variables Declaration Statements Named Constant Assignment Statements Intrinsic (Built-in) Functions
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
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 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 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 informationFull file at C How to Program, 6/e Multiple Choice Test Bank
2.1 Introduction 2.2 A Simple Program: Printing a Line of Text 2.1 Lines beginning with let the computer know that the rest of the line is a comment. (a) /* (b) ** (c) REM (d)
More informationMicrosoft Visual Basic 2005: Reloaded
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program Objectives After studying this chapter, you should be able to: Include the selection structure in pseudocode
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 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 informationA Beginner s Guide to Programming Logic, Introductory. Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs
A Beginner s Guide to Programming Logic, Introductory Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs Objectives In this chapter, you will learn about: Declaring and
More informationGraphQuil Language Reference Manual COMS W4115
GraphQuil Language Reference Manual COMS W4115 Steven Weiner (Systems Architect), Jon Paul (Manager), John Heizelman (Language Guru), Gemma Ragozzine (Tester) Chapter 1 - Introduction Chapter 2 - Types
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 informationC: How to Program. Week /Mar/05
1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers
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 informationIndex. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309
A Arithmetic operation floating-point arithmetic, 11 12 integer numbers, 9 11 Arrays, 97 copying, 59 60 creation, 48 elements, 48 empty arrays and vectors, 57 58 executable program, 49 expressions, 48
More informationData 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 informationAngela Z: A Language that facilitate the Matrix wise operations Language Reference Manual
Angela Z: A Language that facilitate the Matrix wise operations Language Reference Manual Contents Fei Liu, Mengdi Zhang, Taikun Liu, Jiayi Yan 1. Language definition 3 1.1. Usage 3 1.2. What special feature
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 informationModel Viva Questions for Programming in C lab
Model Viva Questions for Programming in C lab Title of the Practical: Assignment to prepare general algorithms and flow chart. Q1: What is a flowchart? A1: A flowchart is a diagram that shows a continuous
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 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 informationVba Variables Constant and Data types in Excel
Vba Variables Constant and Data types in Excel VARIABLES In Excel VBA, variables are areas allocated by the computer memory to hold data. Data stored inside the computer memory has 4 properties: names,
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 information2 nd Week Lecture Notes
2 nd Week Lecture Notes Scope of variables All the variables that we intend to use in a program must have been declared with its type specifier in an earlier point in the code, like we did in the previous
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 information1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical d.
Gaddis: Starting Out with Python, 2e - Test Bank Chapter Two MULTIPLE CHOICE 1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical
More informationProgrammers should write code that is self-documenting and split into small sections.
Writing Programs What are good program writing techniques? Programmers should write code that is self-documenting and split into small sections. Specifically, the programmers should: use meaningful identifier
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 informationIntroduction to Programming
Introduction to Programming session 6 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Spring 2011 These slides are created using Deitel s slides Sharif University of Technology Outlines
More informationComputers Programming Course 6. Iulian Năstac
Computers Programming Course 6 Iulian Năstac Recap from previous course Data types four basic arithmetic type specifiers: char int float double void optional specifiers: signed, unsigned short long 2 Recap
More information1 Lexical Considerations
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler
More informationGeoCode Language Reference Manual
GeoCode Language Reference Manual Contents 1 Introduction... 3 2 Lexical Elements... 3 2.1 Identifiers... 3 2.2 Keywords... 3 2.3 Literals... 3 2.4 Line Structure... 4 2.5 Indentation... 4 2.6 Whitespace...
More informationChapter 2. Lexical Elements & Operators
Chapter 2. Lexical Elements & Operators Byoung-Tak Zhang TA: Hanock Kwak Biointelligence Laboratory School of Computer Science and Engineering Seoul National Univertisy http://bi.snu.ac.kr The C System
More informationBITG 1233: Introduction to C++
BITG 1233: Introduction to C++ 1 Learning Outcomes At the end of this lecture, you should be able to: Identify basic structure of C++ program (pg 3) Describe the concepts of : Character set. (pg 11) Token
More informationPetros: A Multi-purpose Text File Manipulation Language
Petros: A Multi-purpose Text File Manipulation Language Language Reference Manual Joseph Sherrick js2778@columbia.edu June 20, 2008 Table of Contents 1 Introduction...................................................
More informationCreating a C++ Program
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer. 1 Creating a C++ Program created using an
More informationDATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6)
Technology & Information Management Instructor: Michael Kremer, Ph.D. Database Program: Microsoft Access Series DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6) AGENDA 3. Executing VBA
More informationChapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic
More informationOperators and Expressions
Operators and Expressions Conversions. Widening and Narrowing Primitive Conversions Widening and Narrowing Reference Conversions Conversions up the type hierarchy are called widening reference conversions
More informationVBScript: Math Functions
C h a p t e r 3 VBScript: Math Functions In this chapter, you will learn how to use the following VBScript functions to World Class standards: 1. Writing Math Equations in VBScripts 2. Beginning a New
More informationProgram Fundamentals
Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java
More informationused for US Census; Holes were made to represent information to be tabulated were punched in cards; Successful
Essential Standard: 1.00 Understand ethics, security and the history of computer programming Indicator 1.01 Understand the evolution of computers and computer programming languages Indicator 1.02 Understand
More informationIntro to Computer Programming (ICP) Rab Nawaz Jadoon
Intro to Computer Programming (ICP) Rab Nawaz Jadoon DCS COMSATS Institute of Information Technology Assistant Professor COMSATS IIT, Abbottabad Pakistan Introduction to Computer Programming (ICP) What
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 informationCS 211 Programming Practicum Fall 2018
Due: Wednesday, 11/7/18 at 11:59 pm Infix Expression Evaluator Programming Project 5 For this lab, write a C++ program that will evaluate an infix expression. The algorithm REQUIRED for this program will
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 information1.3b Type Conversion
1.3b Type Conversion Type Conversion When we write expressions involved data that involves two different data types, such as multiplying an integer and floating point number, we need to perform a type
More information\n is used in a string to indicate the newline character. An expression produces data. The simplest expression
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 information