VARIABLES: Your Own Piece of the ram. Why Use Variables? To save a piece of data in memory To save a piece of data in memory To store results of a calculation.

Slides:



Advertisements
Similar presentations
Ch. 3 Variables VB.Net Programming. Data Types Boolean – True or False values Short – Small integers (+/- 32,767) Integer – Medium-size integers (+/-
Advertisements

Introduction to Computing Concepts Note Set 7. Overview Variables Data Types Basic Arithmetic Expressions ▫ Arithmetic.
Objective: Dealing with data in C++ Agenda: Notes Essay Help.
Animation Mrs. C. Furman. Animation  We can animate our crab by switching the image between two pictures.  crab.png and crab2.png.
Java Syntax Part I Comments Identifiers Primitive Data Types Assignment.
CIS 234: Using Data in Java Thanks to Dr. Ralph D. Westfall.
Declaring Variables You must first declare a variable before you can use it! Declaring involves: – Establishing the variable’s spot in memory – Specifying.
CSI 101 Elements of Computing Spring 2009 Lecture #6: Data Types and Variables in Visual Basic Wednesday, Februrary 11th, 2009.
Variables, Data Types, & Arithmetic Expressions CSC 1401: Introduction to Programming with Java Lecture 3 Wanda M. Kunkle.
ITP 150 Week 4 Variables. ITP Lecturer: A. Borquez2 Review:  Controls  Propeties  Events  Methods  Procedures  Functions BackStyleFillColor.
CIS 115 Lecture 5.  A storage location in memory (RAM)  Holds data/information while the program is running  These storage locations can be referred.
Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.
Variables and Constants
Mr C Johnston ICT Teacher BTEC IT Unit 06 - Lesson 05 Learning To Program.
CPS120: Introduction to Computer Science Variables and Constants Lecture 8 - B.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
CPS120: Introduction to Computer Science
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Primitive Variables.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Data Types and Variables. Data Type! Computers are all about Data! Data can be in the form of Text Dates Sounds Pictures.
Chapter 3 P. 1 Data - Variables and Constants Definition A variable is a value which can change during program execution. A constant is a value which can.
A variable is a storage location for some type of value. days 102 taxrate 7.75 int days = 102; double taxrate = 7.75; char grade = ‘A’; boolean done.
Variables in Java x = 3;. What is a variable?  A variable is a placeholder in memory used by programmers to store information for a certain amount of.
Variable, Constants and Calculations Dr Mohammad Nabil Almunawar.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Introduction to Programming Lecture Note - 2 Visual Basic Programming Fundamentals.
Data Tonga Institute of Higher Education. Variables Programs need to remember values.  Example: A program that keeps track of sales needs to remember.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
Variables and Constants Objectives F To understand Identifiers, Variables, and Constants.
Variables Hold information that may be manipulated, used to manipulate other information or remembered for later use A storage location in memory (RAM)
Variables in VB.NET. Variables  A storage location in memory (RAM)  Holds data/information while the program is running  These storage locations can.
1.2 Primitive Data Types and Variables
CPS120: Introduction to Computer Science Variables and Constants.
Introduction ABAP Fields and Variables. Slide 2 Fields (Introduction) In ABAP, fields (or data objects) are named locations in memory Variables store.
Murach, Chapter 4. Two Data Types Value Types – Store their own data Reference Types Do not store their own data Stores a reference to an area of memory.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
 Variables can store data of different types, and different data types can do different things.  PHP supports the following data types:  String  Integer.
Variables in VB. What is a variable? ► A named memory location that stores a value.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
DATA TYPES, VARIABLES AND CONSTANTS. LEARNING OBJECTIVES  Be able to identify and explain the difference between data and information  Be able to identify,
Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program.
CIS 338: VB Variables Dr. Ralph D. Westfall April, 2011.
1 st Semester Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
Making Interactive Programs with Visual Basic .NET
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are used in programs so that values can be represented with.
© 2006 Lawrenceville Press Slide 1 Chapter 4 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration statement. For example: Dim.
Introduction to Computer CC111 Week 09 Visual Basic 2 Visual Basic Variables 1.
Objects Allow us to represent and control the computer technology Use methods to make the object do something Use properties to find out and change the.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
A variable is a name for a value stored in memory.
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Visual Basic Variables
Documentation Need to have documentation in all programs
IDENTIFIERS CSC 111.
Microsoft Visual Basic 2005 BASICS
Numbers.
Unit-1 Introduction to Java
C++ Data Types Data Type
Chapter 2: Java Fundamentals
CHAPTER FOUR VARIABLES AND CONSTANTS
Variables Here we go.
C# Revision Cards Data types
GCSE Computing:: Selection (IF statements)
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Variables and Constants
Presentation transcript:

VARIABLES: Your Own Piece of the ram

Why Use Variables? To save a piece of data in memory To save a piece of data in memory To store results of a calculation To store results of a calculation To make code easier to modify/understand To make code easier to modify/understand

A variable is a named memory location that stores a value.

Variables must be declared before they can be used! DimIntlength As Integer Intlength - variable name Integer - data type Dim - stands for dimension As – reserved word

Variable Naming Rules Must begin with a letter. Must begin with a letter. Must only contain letters, digits, and underscores (_). Must only contain letters, digits, and underscores (_). Must not be a keyword (i.e. End, Sub, If). Must not be a keyword (i.e. End, Sub, If). Use the proper abbreviation Use the proper abbreviation (on the naming convention slide). (on the naming convention slide).

Naming Conventions Shortsrt Integerint Longlng Decimaldec Single sng Doubledbl Stringstr Charchr Datedte Booleanbln

Variable Data Types Numbers ( Whole Numbers or Decimals) Numbers ( Whole Numbers or Decimals) Whole Numbers Short, Integer, Long Decimal Single, Double,Decimal Text (String or Char) Text (String or Char) Dates (Date) Dates (Date) State (True or False: Boolean) State (True or False: Boolean)

How Do You Choose What Data Type to Use? Short -32,768 to 32,767 Integer-2,147,483,648 to 2,147,483,647 Longlarge integers Singlenumbers containing a decimal Doublelarge decimal numbers Date dates in m/d/yyyy format Decimalnumbers used for currency Chara single character Stringa set of characters in “ ” BooleanTrue or False

What Data Type Do You Use? 1. Number of students in class 2. Class average Choices 3. Name of the School 4. Grade Given as a Letter

What Kind of Variable Do You Use? 5. Distance to the Moon 6. Has the Bill Been Paid? Choices 7. Cost of a pizza 8. Date of the Last Day of School

Declaration Statements 1. Number of students in class 2. Class average 3. Name of the School 4. Grade Given as a Letter 5. Distance to the Moon 6. Has the Bill Been Paid? 7. Cost of a pizza 8. Date of the Last Day of School Dim srtstudent as short Dim srtstudent as short _______________________________ _________________________