# Outline. Data and Operations. Data Types. Integral Types

Size: px
Start display at page:

Transcription

1 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 2 Data Types Integral Types In computers data such as integers, real numbers, character, strings, and Boolean are represented and stored in memory differently. 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 An integer type has a value as a whole number either negative or positive, e.g., 23, +23, 23, Visual Basic.NET has different integral types depends on the size of the storage. For examples, Byte -- byte Short -- 2 bytes Integer -- 4 bytes Long -- 8 bytes Data and Operations 3 Data and Operations 4

2 Floating-Point Numbers Exponential Notation 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., 8., +9.2, 35.25,.57, 38.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 is commonly used to express both very large and very small floating point numbers in a compact form, e.g.,.74536e 2, E4, 7E2 It is similar to scientific notation. 234 Decimal Notation Exponential Notation.234E E5.234E 2.234E 4 Scientific Notation Data and Operations 5 Data and Operations 6 Strings ASCII Code 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. J o e A B C D E F G H I J K L N O P Q R S T U V W X Y M Z Data and Operations 7 Data and Operations 8 2

3 Boolean There are only two Boolean data values in Visual Basic. These values are the constants: True and False. The Boolean constants are used in decisionmaking statements. Fundamental VB.NET Data Types Type Size in Bytes Description Range of Values Byte 8-bit unsigned integer Integer 4 32-bit signed integer Long 8 64-bit signed integer Short 2 6-bit signed integer 32,768-32,767 Single 4 32-bit floating point variable 3.4E38-3.4E+38 Double 8 64-bit floating point variable.7e38 -.7E+38 Decimal 6 28-bit floating point variables Char 2 6-bit Unicode characters - 65,535 String Varies Non-Numeric Type Boolean Non-Numeric Type False or True Date 8 Non-Numeric Type :: on January, :59:59 on December 3, 9999 Object 4 Non-Numeric Type Reference to an object Data and Operations 9 Data and Operations 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 ^ Exponentiation Mod Modulus -- return remainder Data and Operations Data and Operations 2 3

4 Precedence of Arithmetic Operations Operator Operation ^ Exponentiation Negation * / Multiplication and Division \ Integer Division Mod Modulus -- return remainder + Addition and Subtraction 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. ( + 2) (3) is invalid. Data and Operations 3 Data and Operations 4 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. 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 Data and Operations 5 Data and Operations 6 4

5 Arithmetic Expression Integer Division Operator Expression / 4.6 *.879 / (4.6 *.879) *.879 Result Type Integer Floating Point Floating Point Floating Point VB.NET uses back slash (\) as integer division operator. Expression \4 \4.6.36\4.36\4.6 Actual Value \4 = 2.75 \5 = 2.2 \4 = 2.75 \5 = 2.2 Result Data and Operations 7 Data and Operations 8 Mod Operator Variables The modulus operator Mod yields the remainder of the result of dividing its first operand by its second. Expression Mod 4 2 Mod 4 Mod Mod 4.6 Actual Value 4 = 2 r = 4 r 4.6 = 2 r = 2 r 2.6 Result A variable is a name given by the programmer to a memory storage location. The value stored in a variable can be changed and referenced. The rules that the programmer must follow when selecting a variable name are: The name must begin with a letter or an underscore. The name can only consist of letters, numeric digits, or underscores. The name cannot exceed 6,383 characters. The name cannot be a Visual Basic keyword, such as Integer. A variable name should be chosen to indicate what it represents -- Width, Length, Area, Total_Sum, EmployeeIncome, Interest_Rate. Data and Operations 9 Data and Operations 2 5

6 Declaration Statements A declaration statement is a step used for naming a variable and specifying the data type that can be stored in it. Declaration statements placed within a procedure are non-executable statements that have the general syntax: Dim variable-name As data-type type where data-type designates a Visual Basic data types and variable-name is a variable name selected by the programmer. Examples Dim Number As Integer Dim Wages As Single Dim Last_Name As String Dim MiddleIntial As Char Dim Empty As Boolean Data and Operations 2 Data and Operations 22 Single-line Declarations Visual Basic allows combining multiple declarations into one statement, using the syntax: Dim var- As data-type type, var-2 As data-type type,...,,...,var-n As data-type type Examples: Dim FirstName As String, LastName As data-type, MiddleInit As Char, Test As Integer, Test2 As Integer, Average As Single Dim Test, Test2, Test3, FianlExam As Integer, Average As Single Initialization An initialization is the process of storing a value in a variable for the first time. In Visual Basic, by default, all numeric variables are initialized to zero and all strings are initialized to zero-length strings (strings containing no characters). 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. Data and Operations 23 Data and Operations 24 6

7 Named Constants or Literals 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 data-type type = expression A named constant is a symbolic name assigned to a constant. A named constant cannot be altered after it is defined. The rules for selecting a constant s name are the same as the rules for selecting a variable s name. 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 Examples Const HourlyRate As Byte = 5 Const Weekly As Byte = 4 Const PI As Single = 3.4 Const SalesTax As Double =.825 Data and Operations 25 Data and Operations 26 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 + Sum = Sum + Data Area = Height * Width AverageScore = TotalSum / NemberOfScores Solution = Math.Sqrt(B^2 2*A*C) Data and Operations 27 Data and Operations 28 7

8 Assignment Statements Assignment Variations Data location: 2345 Data2 location: Consider following actions that a computer will perform: put 65 in location 2345 put 49 in location 6789 Add the content of location 2345 to the content of location 6789 store the sum in location The programming version is as follows: Data = 65 Data2 = 49 Sum = Data + 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 29 Data and Operations 3 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 + Count += Data and Operations 3 Data and Operations 32 8

9 Type Conversions Examples When an assignment statement is used, the expression on the right side of the assignment operator is converted to the data type of the variable to the left of the assignment operator. In addition, Visual Basic also provides for explicit user-specified type conversions. Expression Dim Average As Integer Average = 98 / Dim NumberString As Integer NumberString = Dim Number As Single Number = Assigned Value Average = NumberString = Number =. Data and Operations 33 Data and Operations 34 Function Name and Arguments Asc(string) Chr(val) CBool(expression) CByte(expression) CChar(expression) CDate(expression) CDbl(expression) CDec(expression) CInt(expression) CLng(expression) CObj(expression) CShort(expression) CSng(expression) CStr(expression) CType(expression, type) Val(string) 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. 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. 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. Convert a numeric value or sting expression to a Single. Convert an expression to a String. Convert an expression to a specified type. Return the first numeric value of the string. Intrinsic (Built-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. Data and Operations 35 Data and Operations 36 9

10 Examples Examples Function Name Math.Sqrt(9) Description Square root Returned Value 3 Function Name Val( ) CStr() Description Convert string to value Convert value to string Returned Value Math.Abs(-42) Math.Round(4.779, 2) Absolute value Round Int(99.8) CInt(99.8) Round to nearest integer less than or equal to the number Round to nearest integer 99 Math.Log(24.22) Log Ceiling(99.8) Floor(99.8) Returns the smallest integer greater than the number Returns the integer largest less than the number 99 Data and Operations 37 Data and Operations 38 Common Programming Errors and Problems The most common errors associated with the material presented in this chapter that students should be aware of are: Misspelling the name of a method. Forgetting to close string messages to be displayed by the MessageBox.Show method within double quote symbols. Incorrectly typing the letter O for the number zero (), and vice versa. Incorrectly typing the letter l, for the number, and vice versa. Forgetting to declare all the variables used in a program. Storing an inappropriate data type value in a declared variable. Using a variable in an expression before an explicit value has been assigned to the variable. Using an intrinsic function without providing the correct number of arguments of the proper data type. Being unwilling to test an event procedure in depth Data and Operations 39

### Data 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

### 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

### CSc 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

### Review: 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

### Lecture 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

### VB.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

### C++ 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

### Full 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

### These 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.

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

### Murach 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

### Chapter 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

### CSE 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

### UNIT- 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

### XQ: An XML Query Language Language Reference Manual

XQ: An XML Query Language Language Reference Manual Kin Ng kn2006@columbia.edu 1. Introduction XQ is a query language for XML documents. This language enables programmers to express queries in a few simple

### Objectives. 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

### Chapter 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

### ! 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

### COMP 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

### Reserved 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

### JAVA 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

### Computer 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

### On 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.

### Chapter 2 Working with Data Types and Operators

JavaScript, Fourth Edition 2-1 Chapter 2 Working with Data Types and Operators At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics

### BASIC 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

### The 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

### Objectives. 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

### Chapter 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

### Chapter 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

### Programming 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

### Declaration 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

### Features 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

### Data 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

### Chapter 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++

### Objectives. Data Types (continued) Data Types 4. การเข ยนโปรแกรมพ นฐาน ว ทยาการคอมพ วเตอร เบ องต น Fundamentals of Computer Science

204111 ว ทยาการคอมพ วเตอร เบ องต น Fundamentals of Computer Science ภาคการศ กษาท ภาคการศกษาท 1 ป ปการศกษา การศ กษา 2556 4. การเข ยนโปรแกรมพ นฐาน 4.2 ต วแปร น พจน และการก าหนดค า รวบรวมโดย อ. ดร. อาร ร

### Chapter 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

### Basic 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

### Bits, 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

### Java 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.)

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

### LECTURE 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

### Basics 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

### COMP1730/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?

### CHAPTER 3 BASIC INSTRUCTION OF C++

CHAPTER 3 BASIC INSTRUCTION OF C++ MOHD HATTA BIN HJ MOHAMED ALI Computer programming (BFC 20802) Subtopics 2 Parts of a C++ Program Classes and Objects The #include Directive Variables and Literals Identifiers

### 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

### BEGINNING PROBLEM-SOLVING CONCEPTS FOR THE COMPUTER. Chapter 2

1 BEGINNING PROBLEM-SOLVING CONCEPTS FOR THE COMPUTER Chapter 2 2 3 Types of Problems that can be solved on computers : Computational problems involving some kind of mathematical processing Logical Problems

### 2.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

### COMP 110 Introduction to Programming. What did we discuss?

COMP 110 Introduction to Programming Fall 2015 Time: TR 9:30 10:45 Room: AR 121 (Hanes Art Center) Jay Aikat FB 314, aikat@cs.unc.edu Previous Class What did we discuss? COMP 110 Fall 2015 2 1 Today Announcements

### Today. o main function. o cout object. o Allocate space for data to be used in the program. o The data can be changed

CS 150 Introduction to Computer Science I Data Types Today Last we covered o main function o cout object o How data that is used by a program can be declared and stored Today we will o Investigate the

### Ex: 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:

### Operators. 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

### Zheng-Liang Lu Java Programming 45 / 79

1 class Lecture2 { 2 3 "Elementray Programming" 4 5 } 6 7 / References 8 [1] Ch. 2 in YDL 9 [2] Ch. 2 and 3 in Sharan 10 [3] Ch. 2 in HS 11 / Zheng-Liang Lu Java Programming 45 / 79 Example Given a radius

### Microsoft 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

### EDIABAS 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

### Quick Reference Guide

SOFTWARE AND HARDWARE SOLUTIONS FOR THE EMBEDDED WORLD mikroelektronika Development tools - Books - Compilers Quick Reference Quick Reference Guide with EXAMPLES for Basic language This reference guide

### Full 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

### MATVEC: 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

### CSCE 120: Learning To Code

CSCE 120: Learning To Code Manipulating Data I Introduction This module is designed to get you started working with data by understanding and using variables and data types in JavaScript. It will also

### Lecture Numbers. Richard E Sarkis CSC 161: The Art of Programming

Lecture Numbers Richard E Sarkis CSC 161: The Art of Programming Class Administrivia Agenda To understand the concept of data types To be familiar with the basic numeric data types in Python To be able

### Introduction 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

### 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

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

### LECTURE 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

### A First Program - Greeting.cpp

C++ Basics A First Program - Greeting.cpp Preprocessor directives Function named main() indicates start of program // Program: Display greetings #include using namespace std; int main() { cout

### Chapter 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

### Programming 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()

### Expressions 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

### 3. 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

### C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018

C++ Basics Lecture 2 COP 3014 Spring 2018 January 8, 2018 Structure of a C++ Program Sequence of statements, typically grouped into functions. function: a subprogram. a section of a program performing

### Chapter 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

### Fundamentals 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

### DEPARTMENT 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,

### 7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING

KEY CONCEPTS COMP 10 EXPLORING COMPUTER SCIENCE Lecture 2 Variables, Types, and Programs Problem Definition of task to be performed (by a computer) Algorithm A particular sequence of steps that will solve

### Expressions 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

### Language 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

### C++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.

EEE-117 COMPUTER PROGRAMMING Basic Elements of C++ Objectives General Questions Become familiar with the basic components of a C++ program functions, special symbols, and identifiers Data types Arithmetic

### LESSON 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

### REVIEW. The C++ Programming Language. CS 151 Review #2

REVIEW The C++ Programming Language Computer programming courses generally concentrate on program design that can be applied to any number of programming languages on the market. It is imperative, however,

### การเขยนโปรแกรมพนฐาน ภาคการศ กษาท 1 ป การศ กษา การเข ยนโปรแกรมพ นฐาน ว ทยาการคอมพ วเตอร เบ องต วทยาการคอมพวเตอรเบองตน น

204111 ว ทยาการคอมพ วเตอร เบ องต วทยาการคอมพวเตอรเบองตน น Fundamentals of Computer Science ภาคการศ กษาท 1 ป การศ กษา 2556 4. การเข ยนโปรแกรมพ นฐาน การเขยนโปรแกรมพนฐาน 4.2 ต วแปร น พจน และการก าหนดค า รวบรวมโดย

### Work 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

### Agenda & 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

### C: 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

### C Programming

204216 -- C Programming Chapter 3 Processing and Interactive Input Adapted/Assembled for 204216 by Areerat Trongratsameethong A First Book of ANSI C, Fourth Edition Objectives Assignment Mathematical Library

### Fundamental 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

### Will 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

### Programming 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

### Week 2: Console I/O and Operators Arithmetic Operators. Integer Division. Arithmetic Operators. Gaddis: Chapter 3 (2.14,3.1-6,3.9-10,5.

Week 2: Console I/O and Operators Gaddis: Chapter 3 (2.14,3.1-6,3.9-10,5.1) CS 1428 Fall 2014 Jill Seaman 1 2.14 Arithmetic Operators An operator is a symbol that tells the computer to perform specific

### Lecture 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

### Language 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,

### 3. Java - Language Constructs I

Educational Objectives 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions You know the basic blocks

### CIS 110: Introduction to Computer Programming

CIS 110: Introduction to Computer Programming Lecture 3 Express Yourself ( 2.1) 9/16/2011 CIS 110 (11fa) - University of Pennsylvania 1 Outline 1. Data representation and types 2. Expressions 9/16/2011

### Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Contents 1 Introduction...2 2 Lexical Conventions...2 3 Types...3 4 Syntax...3 5 Expressions...4 6 Declarations...8 7 Statements...9

### CHAPTER 3: CORE PROGRAMMING ELEMENTS

Variables CHAPTER 3: CORE PROGRAMMING ELEMENTS Introduction to Computer Science Using Ruby A variable is a single datum or an accumulation of data attached to a name The datum is (or data are) stored in

### Expressions 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

### 2/29/2016. Definition: Computer Program. A simple model of the computer. Example: Computer Program. Data types, variables, constants

Data types, variables, constants Outline.1 Introduction. Text.3 Memory Concepts.4 Naming Convention of Variables.5 Arithmetic in C.6 Type Conversion Definition: Computer Program A Computer program is a

### Chapter 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

### Chapter 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

### Learning Language. Reference Manual. George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104)

Learning Language Reference Manual 1 George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104) A. Introduction Learning Language is a programming language designed