Agenda & Reading. VB.NET Programming. Data Types. COMPSCI 280 S1 Applications Programming. Programming Fundamentals
|
|
- Brittany Hall
- 6 years ago
- Views:
Transcription
1 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 ting Recommended Reading: Data s in Visual Basic Advanced Programming Using Visual Basic.NET Appendix B: Visual Basic Review of Introductory of VB.NET Concepts Microsoft Visual Basic 005 Step by Step Chapter 5: Visual Basic Variables and Formulas Hands-On Lab: Lab04 COMPSCI VB.NET Programming VB.NET Has achieved popularity and widespread acceptance Is a powerful, full-featured, object-oriented development language Is easy to learn and use Note: Code is not case sensitive VB.NET compiler does not require indentation of code, but good programming practice encourages indentation Comment lines: Begin with a single quote (') Add explanations to code Are ignored by compiler COMPSCI Data s Visual Basic.NET supplies a set of pre-defined data types that you can use for many of your programming elements s are divided into two categories: Value s store data directly in the variable Numeric Data s Integral and nonintegral numeric types Boolean, Char and Date Structure Enumerations Reference s store a memory address (address of the actual object in memory) in the variable String Arrays Class s COMPSCI
2 Value s : Numeric Integral s Data types for numeric data without decimals Byte Short Integer Long Size (bytes) 4 8 NonIntegral s Range 0 through through ,47,483,648 through,47,483,647-9,3,37,036,854,775,808 through 9,3,37,036,854,775,807 Data types for numeric data with decimals Float and double implement the specification of the IEEE 754 format types Decimal: smaller range, but has more precision, is typically useful in financial calculations Single Double Decimal Size 3-bit floating point 64-bit floating point 8-bit fixed point COMPSCI Value s (con t) char type char Size Helpful methods: Char.IsDigit() Stores a unicode character Indicates whether a Unicode character is categorized as a decimal digit. Char.IsPunctuation() Indicates whether the specified Unicode character is categorized as a punctuation mark. Char.IsLetter() Indicates whether a Unicode character is categorized as an alphabetic letter. Console.WriteLine(Char.IsDigit(CharVar)) COMPSCI Value s (con t) Boolean Discusses true and false values. When numeric data types are converted to Boolean values, 0 becomes False and all other values become True. When Boolean values are converted to numeric types, False becomes 0 and True becomes Cbool -> - Convert.ToInt3 -> Date Dim mybirthday As Date mybirthday = #3//006 07:00 AM# Discusses date and time values. Date values must be enclosed within number signs (#) and be in the format M/d/yyyy, for example #5/3/993#. If you do not include a time in a date/time literal, VB sets the time part of the value to the start of the day, that is, midnight. Boolean Date Size (bytes) 8 Range True or False January, 000 through December 3, 9999 COMPSCI Value s (con t) Structure A structure is a generalization of the user-defined type (UDT) supported by previous versions of Visual Basic. In addition to fields, structures can expose properties, methods, and events You can combine data items of different types to create a structure Structures are useful when you want a single variable to hold several related pieces of information. Examples: Public Structure Int3 Public Const MaxValue As Integer Public Const MinValue As Integer Public Function ToString As String End Function End Structure Dim intmax As Integer = Int3.MaxValue Console.WriteLine(intMax) COMPSCI
3 Reference s String The String data type is a sequence of zero or more two-byte (6- bit) Unicode characters. The default value of String is Nothing (a null reference). Note that this is not the same as the empty string (value ""). Object Object variables are stored as 3-bit (4-byte) addresses that refer to objects. Array An array allows you to refer to these related values by the same name and to use a number, called an index or subscript, to tell them apart. The individual values are called the elements of the array. They are contiguous from index 0 through the highest index value COMPSCI What is an Object Each object in Visual Basic.NET is defined by a class. Classes describe the fields, properties, methods, and events of an object. Objects are instances of classes; you can create as many objects you need once you have created a class. Examples: Cookie cutters and cookies. The cookie cutter is the class. It defines the characteristics of each cookie for instance, size and shape. The class is used to create objects. The objects are the cookies. Controls The controls on the Toolbox in Visual Basic.NET represent classes. When you drag and drop a control from the toolbox onto a form, you are actually creating an object an instance of a class. COMPSCI Working with Objects Instantiating an Object Instantiation is the process by which an instance of a class is created and assigned to an object variable. Fields and Properties Dim p As New MyPoint() Properties and fields represent information stored in an object. x and y coordinates of a Point object Methods Methods are procedures defined within a class. ToString(): Converts this Point to a human-readable string. Member Access Accessing the members of an object by specifying, in order, the name of the object, a period, and the name of the member you want to use. COMPSCI Value s Vs Reference s Value s Value types are stored directly on the stack. Their storage can only be accessed directly. A variable of a value type always contains a value of that type. For a variable of a value type, the default value is the result of initializing each variable member of the type to its default value. Reference s Reference s are stored on the run-time heap; they may only be accessed through a reference to that storage. A variable of reference type contains a reference to a value of that type. For a variable of a reference type, the default value is a null reference. y 3 COMPSCI x 4
4 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 A variable declaration is a statement that causes Visual Basic.NET to create a variable in memory To declare a VB.NET variable: Syntax: Dim is a keyword VariableName is the name to be used As is a keyword Data is the type of the variable Variable Naming Conventions Dim VariableName As Data Dim i As Integer Each variable name should describe its use, e.g., itemsordered When multiple words are used in a name, capitalize the initials, except for the first one (again, itemsordered) Certain names should have a specific prefix, e.g., txt for Text Boxes, btn for Buttons COMPSCI Assigning Data to Variables Assignment operator (=) assigns the value on the right to the variable named on the left side i = To declare and initialize a variable can be written in one statement Dim i As Integer = Several variables of the same data type can be declared in one statement Dim i, j, k As Integer If no value is assigned when declared Numeric variables have an initial value of 0 Boolean variables have an initial value of False Date variables have an initial value of //000 String and object variables have an initial value of nothing COMPSCI Constants A constant also has a name and data type. But the values stored in constants cannot change. Constant must be initialized in the statement that declares them By convention, constant names are capitalized Examples: Const WIDTH As Integer = 00 Const PI = Const VERSION = "07.0.A Const PI = PI * To declare multiple constants on a single line: Const Four As Integer = 4, Five As Integer = 5, Six As Integer = 44 COMPSCI Literals "He said, ""I like it. """ String Literals String literals may contain letters, digits, and special characters and they are enclosed in quotation marks If you want to include quotation marks inside a string literal, use two quotation marks together You can force a literal to a particular data type by appending a type-declaration character. Data Short Integer Long Decimal Single Double Char Character S I L D F R C Example AGE = 35S HOURS = 40I POPULATION=0500L RATE = 0.3D RATE = 0.3F SALES=356R a C COMPSCI
5 Enumerations Enumerations provide a convenient way to work with sets of related constants and to associate constant values with names. Visual Basic provides a number of useful enumerations. Example: Date Enumeration LongDate ShortDate LongTime ShortTime Use DateTime() Function to returns a string expression representing a date/time value. Dim TestDate As DateTime = #3//999# Dim strdate As String strdate = DateTime(TestDate, Date.LongDate) Console.WriteLine(strDate) User-defined enumeration: Friday, March, 999 Enum MyDays Sat Sun Console.WriteLine(Days.Sat) COMPSCI 80 End Enum 04 7 Conversions Converting data from one type to another is called type conversion Conversions are either widening or narrowing, depending on the data capacities of the types involved: Widening Conversion A conversion changes a value to a data type that can accommodate any possible value of the original data. Examples: Byte -> Short/Integer/Long/Decimal/Single/Double Single -> Double Narrowing conversion A conversion changes a value to a data type that might not be able to hold some of the possible values Narrowing conversions do not always succeed at run time, and can fail or incur data loss Double -> Single COMPSCI Conversion Conversions are either implicit or explicit, depending on the syntax in the source code Implicit type conversion An implicit conversion does not require any special syntax in the source code. 4.0 Integer will implicitly convert to single Explicit type conversion An explicit conversion uses type conversion keywords, or Dim k As Integer Dim q As Single k = 4 q = k Dim b As Single =.4 Dim i As Integer i = CInt(b) Console.WriteLine(i) functions of the System.Convert class, or functions on an individual type structure or class. COMPSCI Conversion keywords Conversion Functions coerce an expression in parentheses to the desired data type. These keywords act like functions, but the compiler generates the code inline, so execution is slightly faster than with a function call. Keyword CBool(expression) CChar(expression) CInt(expression) C(expression, DestinationData) Range for expression argument Any valid Char or String or numeric expression. Any valid Char or String expression; only first character of a String is converted; value can be 0 through (unsigned). -,47,483,648 through,47,483,647; fractional parts are rounded. coerces expression to DestinationData, where DestinationData can be any data type, structure, or class to which there exists a valid conversion. COMPSCI
6 The Convert Class & Parse Method The convert class The Convert class contains methods to convert a base data type to another base data type. ToBoolean ToInt3(Single) The parse method Every numeric data type in Visual Basic.NET has a Parse method that can be used to convert a string to that numeric data type. This is handy for converting Text Property into a numeric variable without using the VAL function. Syntax: Convert.Toxxx(value) Dim purchase As Double = 500 Dim tax As Decimal = Convert.ToDecimal(purchase) *.03D Dim inumber As Integer = Convert.ToInt3(dNumber) Converts the value to an equivalent Boolean value. Converts the value of the specified single-precision floating point number to an equivalent 3-bit signed integer. numericdata.parse(string) Note: If value is halfway between two whole numbers, the even number is returned Dim sales As Decimal sales = Decimal.Parse(uiSalesTextBox.Text) COMPSCI Boxing and unboxing Boxing and unboxing enable value types to be treated as objects With boxing and unboxing one can link between valuetypes and reference-types by allowing any value of a value type to be converted to and from type object. Boxing Put a value type into an instance of the Object reference type Unboxing i = 3 Dim o As Object = i 'boxing Extract the value type from the object Dim j As Integer = o 'unboxing Note: boxing and unboxing are computationally expensive processes COMPSCI ting The.NET Framework defines standard and custom format specifiers for formatting numbers, dates and times, and enumerations specifiers are used by various methods that format output strings, such as Console.WriteLine and the ToString method of any type. Examples: Using Console.Write/WriteLine Using ToString Character C F N X Description Currency Fixed-point Number Hexadecimal Console.WriteLine("{0:F}",.5) Console.WriteLine("{0:F4}",.5) Dim d As Double =.5 Console.WriteLine(d.ToString("c")) Console.WriteLine(d.ToString("f")) Examples Output $.5.50,500, COMPSCI $ DateTime ting Standard DateTime Strings Consists of a single format specifier character from the following table Dim dt As DateTime = DateTime.Now Console.WriteLine(dt.ToString("d")) Console.WriteLine(dt.ToString("D")) Strings dd ddd dddd DateTime for a specific culture Custom DateTime Strings Meaning current day of the month; -3 abbreviated name of the day full name of the day Strings MM MMM MMMM Meaning the month, - abbreviated name of the month full name of the month German in Germany ci = New System.Globalization.CultureInfo("de-DE") Console.WriteLine(dt.ToString("d", ci)) Console.WriteLine(dt.ToString("dddd, dd - MMMM")) Strings COMPSCI yy yyyy /9/007 Tuesday, 9 January 007 Meaning the year, as a maximum two-digit number (The first two digits of the year are omitted) the year Specifier d/d t/t g/g f/f M,m Name Short/Long date Short/long time Short/long General date/time Short/long Full date/time Month day Y,y Year month Tuesday, 09 - January
7 Option Strict Placed the Option Strict On statement at the very top of the code window this will prevent VB.NET from performing implicit data type conversion from a wider data type to a narrow one, or between String and numeric data types Data loss can occur when the value of one data type is converted to a data type with less precision or smaller capacity Dim x As Integer Dim y As Byte Option Strict Off y = 30 x = y Console.WriteLine(x) 'narrowing conversion x = 300 y = x Console.WriteLine(y) Option Strict On y = 30 x = y Console.WriteLine(x) x = 300 y = x Console.WriteLine(y) Generate Compile-time Compiled OK error COMPSCI 80 Generate run-time error 04 5 Option Explicit VB.NET provides a way to prevent you from using undeclared variables in your code Enter the statement Option Explicit On at the very top of the code window This may already be turned on. Choose Tools->Options, Projects, VBDefaults COMPSCI
Programming 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 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 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 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 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 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 informationSKILL 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 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 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 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 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 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 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 informationUsing Custom Number Formats
APPENDIX B Using Custom Number Formats Although Excel provides a good variety of built-in number formats, you may find that none of these suits your needs. This appendix describes how to create custom
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 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 informationC# MOCK TEST C# MOCK TEST I
http://www.tutorialspoint.com C# MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to C#. You can download these sample mock tests at your local machine
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 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 informationObjectives. Describe ways to create constants const readonly enum
Constants Objectives Describe ways to create constants const readonly enum 2 Motivation Idea of constant is useful makes programs more readable allows more compile time error checking 3 Const Keyword const
More informationJava enum, casts, and others (Select portions of Chapters 4 & 5)
Enum or enumerates types Java enum, casts, and others (Select portions of Chapters 4 & 5) Sharma Chakravarthy Information Technology Laboratory (IT Lab) Computer Science and Engineering Department The
More informationTokens, Expressions and Control Structures
3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type
More informationStandard 11. Lesson 9. Introduction to C++( Up to Operators) 2. List any two benefits of learning C++?(Any two points)
Standard 11 Lesson 9 Introduction to C++( Up to Operators) 2MARKS 1. Why C++ is called hybrid language? C++ supports both procedural and Object Oriented Programming paradigms. Thus, C++ is called as a
More informationChapter-8 DATA TYPES. Introduction. Variable:
Chapter-8 DATA TYPES Introduction To understand any programming languages we need to first understand the elementary concepts which form the building block of that program. The basic building blocks include
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 informationEnableBasic. The Enable Basic language. Modified by Admin on Sep 13, Parent page: Scripting Languages
EnableBasic Old Content - visit altium.com/documentation Modified by Admin on Sep 13, 2017 Parent page: Scripting Languages This Enable Basic Reference provides an overview of the structure of scripts
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 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 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 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 information.Net Technologies. Components of.net Framework
.Net Technologies Components of.net Framework There are many articles are available in the web on this topic; I just want to add one more article over the web by explaining Components of.net Framework.
More informationNCSS Statistical Software. The Data Window
Chapter 103 Introduction This chapter discusses the operation of the NCSS Data Window, one of the four main windows of the NCSS statistical analysis system. The other three windows are the Output Window,
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 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 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 informationCS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation
CS113: Lecture 3 Topics: Variables Data types Arithmetic and Bitwise Operators Order of Evaluation 1 Variables Names of variables: Composed of letters, digits, and the underscore ( ) character. (NO spaces;
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 informationValues and Variables 1 / 30
Values and Variables 1 / 30 Values 2 / 30 Computing Computing is any purposeful activity that marries the representation of some dynamic domain with the representation of some dynamic machine that provides
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 informationComputer Programming, I. Laboratory Manual. Experiment #3. Selections
Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #3
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 informationLecture Notes. System.out.println( Circle radius: + radius + area: + area); radius radius area area value
Lecture Notes 1. Comments a. /* */ b. // 2. Program Structures a. public class ComputeArea { public static void main(string[ ] args) { // input radius // compute area algorithm // output area Actions to
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 informationIntroduction To C#.NET
Introduction To C#.NET Microsoft.Net was formerly known as Next Generation Windows Services(NGWS).It is a completely new platform for developing the next generation of windows/web applications. However
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 informationCMPT 125: Lecture 3 Data and Expressions
CMPT 125: Lecture 3 Data and Expressions Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University January 3, 2009 1 Character Strings A character string is an object in Java,
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 informationJava Basic Datatypees
Basic Datatypees Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in the memory. Based on the data type of a variable,
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 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 informationINTRODUCTION 1 AND REVIEW
INTRODUTION 1 AND REVIEW hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. Programming: Advanced Objectives You will learn: Program structure. Program statements. Datatypes. Pointers. Arrays. Structures.
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 informationQuestion And Answer.
Q.1 What would be the output of the following program? using System; namespaceifta classdatatypes static void Main(string[] args) inti; Console.WriteLine("i is not used inthis program!"); A. i is not used
More informationChapter 1 Getting Started
Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different
More informationTypes and Expressions. Chapter 3
Types and Expressions Chapter 3 Chapter Contents 3.1 Introductory Example: Einstein's Equation 3.2 Primitive Types and Reference Types 3.3 Numeric Types and Expressions 3.4 Assignment Expressions 3.5 Java's
More information10/9/2012. Computers are machines that process data. assignment in C# Primitive Data Types. Creating and Running Your First C# Program
Primitive Data Types 1. Creating and Running Your First C# Program Integer Floating-Point / Decimal Floating-Point Boolean Character String Object Declaring and Using Variables 2. Identifiers Declaring
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 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 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 informationData Types and Expressions
2 Data Types and Expressions C# Programming: From Problem Analysis to Program Design C# Programming: From Problem Analysis to Program Design 1 4th Edition Chapter Objectives C# Programming: From Problem
More informationUniversity of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.
University of Technology Laser & Optoelectronics Engineering Department C++ Lab. Second week Variables Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable.
More informationJOSE LUIS JUAREZ VIVEROS com) has a. non-transferable license to use this Student Guide
Module 3 Identifiers, Keywords, and Types Objectives Upon completion of this module, you should be able to: Use comments in a source program Distinguish between valid and invalid identifiers Recognize
More informationCS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University
CS 112 Introduction to Computing II Wayne Snyder Department Boston University Today: Java basics: Compilation vs Interpretation Program structure Statements Values Variables Types Operators and Expressions
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 information1. Introduction to Microsoft Excel
1. Introduction to Microsoft Excel A spreadsheet is an online version of an accountant's worksheet, which can automatically do most of the calculating for you. You can do budgets, analyze data, or generate
More informationCOMP6700/2140 Data and Types
COMP6700/2140 Data and Types Alexei B Khorev and Josh Milthorpe Research School of Computer Science, ANU February 2017 Alexei B Khorev and Josh Milthorpe (RSCS, ANU) COMP6700/2140 Data and Types February
More informationNOTES: Variables & Constants (module 10)
Computer Science 110 NAME: NOTES: Variables & Constants (module 10) Introduction to Variables A variable is like a container. Like any other container, its purpose is to temporarily hold or store something.
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 informationDatabase Programming with SQL 5-1 Conversion Functions. Copyright 2015, Oracle and/or its affiliates. All rights reserved.
Database Programming with SQL 5-1 Objectives This lesson covers the following objectives: Provide an example of an explicit data-type conversion and an implicit data-type conversion Explain why it is important,
More informationTypes, Variables, and Constants
, Variables, and Constants What is a Type The space in which a value is defined Space All possible allowed values All defined operations Integer Space whole numbers +, -, x No divide 2 tj Why Types No
More informationC How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.
C How to Program, 6/e 1992-2010 by Pearson Education, Inc. An important part of the solution to any problem is the presentation of the results. In this chapter, we discuss in depth the formatting features
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 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 informationPART I. Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++.
Unit - III CHAPTER - 9 INTRODUCTION TO C++ Choose the correct answer. PART I 1. Who developed C++? (a) Charles Babbage (b) Bjarne Stroustrup (c) Bill Gates (d) Sundar Pichai 2. What was the original name
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 informationCEN 414 Java Programming
CEN 414 Java Programming Instructor: H. Esin ÜNAL SPRING 2017 Slides are modified from original slides of Y. Daniel Liang WEEK 2 ELEMENTARY PROGRAMMING 2 Computing the Area of a Circle public class ComputeArea
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 informationChapter 2 Elementary Programming
Chapter 2 Elementary Programming Part I 1 Motivations In the preceding chapter, you learned how to create, compile, and run a Java program. Starting from this chapter, you will learn how to solve practical
More informationJava Classes: Math, Integer A C S L E C T U R E 8
Java Classes: Math, Integer A C S - 1903 L E C T U R E 8 Math class Math class is a utility class You cannot create an instance of Math All references to constants and methods will use the prefix Math.
More informationCSI33 Data Structures
Outline Department of Mathematics and Computer Science Bronx Community College October 24, 2018 Outline Outline 1 Chapter 8: A C++ Introduction For Python Programmers Expressions and Operator Precedence
More informationPIC 10A Pointers, Arrays, and Dynamic Memory Allocation. Ernest Ryu UCLA Mathematics
PIC 10A Pointers, Arrays, and Dynamic Memory Allocation Ernest Ryu UCLA Mathematics Pointers A variable is stored somewhere in memory. The address-of operator & returns the memory address of the variable.
More information3. Except for strings, double quotes, identifiers, and keywords, C++ ignores all white space.
Chapter 2: Problem Solving Using C++ TRUE/FALSE 1. Modular programs are easier to develop, correct, and modify than programs constructed in some other manner. ANS: T PTS: 1 REF: 45 2. One important requirement
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 informationIntroduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types. Record Types. Pointer and Reference Types
Chapter 6 Topics WEEK E FOUR Data Types Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative Arrays Record Types Union Types Pointer and Reference
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 informationComputer Components. Software{ User Programs. Operating System. Hardware
Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point
More informationPreview from Notesale.co.uk Page 6 of 52
Binary System: The information, which it is stored or manipulated by the computer memory it will be done in binary mode. RAM: This is also called as real memory, physical memory or simply memory. In order
More informationCS149: Elements of Computer Science. Fundamental C++ objects
Fundamental C++ objects 1. Compiler needs to know in advance how to store different data types 2. Variable name + type, e.g. (price, integer) 3. Types: (a) Integers: short, long, signed (b) Floating Points:
More informationNumber Representation & Conversion
Number Representation & Conversion Chapter 4 Under the covers of numbers in Java 1 How (Unsigned) Integers Work Base 10 Decimal (People) Base 2 Binary (Computer) 10 2 10 1 10 0 2 3 4 2 7 2 6 2 5 2 4 2
More informationVARIABLES AND CONSTANTS
UNIT 3 Structure VARIABLES AND CONSTANTS Variables and Constants 3.0 Introduction 3.1 Objectives 3.2 Character Set 3.3 Identifiers and Keywords 3.3.1 Rules for Forming Identifiers 3.3.2 Keywords 3.4 Data
More informationBinghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program
Syntax What the Compiler needs to understand your program 1 Pre-Processing Any line that starts with # is a pre-processor directive Pre-processor consumes that entire line Possibly replacing it with other
More informationTypes, Operators and Expressions
Types, Operators and Expressions EECS 2031 18 September 2017 1 Variable Names (2.1) l Combinations of letters, numbers, and underscore character ( _ ) that do not start with a number; are not a keyword.
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 informationFundamental of C programming. - Ompal Singh
Fundamental of C programming - Ompal Singh HISTORY OF C LANGUAGE IN 1960 ALGOL BY INTERNATIONAL COMMITTEE. IT WAS TOO GENERAL AND ABSTRUCT. IN 1963 CPL(COMBINED PROGRAMMING LANGUAGE) WAS DEVELOPED AT CAMBRIDGE
More information1.1 Introduction to C Language. Department of CSE
1.1 Introduction to C Language 1 Department of CSE Objectives To understand the structure of a C-Language Program To write a minimal C program To introduce the include preprocessor command To be able to
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 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 informationAppendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.
A Appendix Grammar There is no worse danger for a teacher than to teach words instead of things. Marc Block Introduction keywords lexical conventions programs expressions statements declarations declarators
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 information