Copyright ©2005  Department of Computer & Information Science Introducing Variables.

Slides:



Advertisements
Similar presentations
Programming Languages and Paradigms
Advertisements

CS324e - Elements of Graphics and Visualization A Little Java A Little Python.
CSCI 1100/ , 6.2, 6.4 April 12, 15, 17.
Chapter 1 OO using C++. Abstract Data Types Before we begin we should know how to accomplish the goal of the program We should know all the input and.
Variables and Constants
1 9/1/06CS150 Introduction to Computer Science 1 What Data Do We Have? CS 150 Introduction to Computer Science I.
Introduction and a Review of Basic Concepts
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
JavaScript, Third Edition
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
Introduction - The Need for Data Structures Data structures organize data –This gives more efficient programs. More powerful computers encourage more complex.
Programming Concepts MIT - AITI. Variables l A variable is a name associated with a piece of data l Variables allow you to store and manipulate data in.
Introduction to Information and Computer Science Computer Programming Lecture c This material (Comp4_Unit5c), was developed by Oregon Health and Science.
 Value, Variable and Data Type  Type Conversion  Arithmetic Expression Evaluation  Scope of variable.
A Level Computing#BristolMet Session Objectives U2#S6 MUST identify different data types used in programming aka variable types SHOULD describe each data.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
A Level Computing#BristolMet Session ObjectivesU2#S10 MUST describe the difference between constants, local and global variables SHOULD explain why constants.
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
Pointer and Array Lists Chapter 3, Summary CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and.
Data Structures and Algorithms Lecture 1 Instructor: Quratulain Date: 1 st Sep, 2009.
Introducing JavaScript. Goals By the end of this lecture you should … Be able to describe the differences among object methods, object properties and.
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
ELEN 033 Lecture #1 Tokunbo Ogunfunmi Santa Clara University.
Copyright Curt Hill Variables What are they? Why do we need them?
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running Types of data.
ENUMERATED DATATYPES. USER DEFINED DATA TYPES  Data Type Defined By Programmer  Allows Use Of More Complex Data  Typically Defined Globally So Variables.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
ITEC 109 Lecture 7 Operations. Review Variables / Methods Functions Assignments –Purpose? –What provides the data? –What stores the data? –What type of.
Component 4: Introduction to Information and Computer Science Unit 5: Overview of Programming Languages, Including Basic Programming Concepts Lecture 3.
Copyright 2010 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
Lecture – Pointers1 C++ Pointers Joseph Spring/Bob Dickerson School of Computer Science Operating Systems and Computer Networks Based on notes by Bob Dickerson.
Programming with Microsoft Visual Basic th Edition
Memory Management in Java Computer Science 3 Gerb Objective: Understand references to composite types in Java.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Python Programming Lecture II. Data Data is the raw material that programs manipulate. Data comes in different flavours. The basic ones are called “primitive.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
Java & C++ Comparisons How important are classes and objects?? What mechanisms exist for input and output?? Are references and pointers the same thing??
int [] scores = new int [10];
Computer Science 1000 Algorithms III. Multiple Inputs suppose I ask you to write a program that computes the area of a rectangle area = length * width.
Arrays Collections of data Winter 2004CS-1010 Dr. Mark L. Hornick 1.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
1 Sections 3.1 – 3.2a Basic Syntax and Semantics Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Copyright © Texas Education Agency, Computer Programming Variables and Data Types.
Bill Tucker Austin Community College COSC 1315
Unit 2 Technology Systems
What Actions Do We Have Part 1
Java Software Solutions
Object Oriented Programming
Revision Lecture
University of Gujrat Department of Computer Science
SSEA Computer Science: CS106A
Fundamentals of Functional Programming Languages
Introduction to the C Language
Building Java Programs Chapter 2
Building Java Programs
Building Java Programs Chapter 2
Lecture Notes - Week 2 Lecture-1. Lecture Notes - Week 2 Lecture-1.
See requirements for practice program on next slide.
Tutorial 10: Programming with javascript
C Programming Pointers
Introducing JavaScript
Building Java Programs Chapter 2
Module 5 ● Vocabulary 1 a sensing block which will ask whatever question is typed into the block and display an input text box at the bottom.
Java Software Solutions
Variables and Constants
Presentation transcript:

Copyright ©2005  Department of Computer & Information Science Introducing Variables

Copyright ©2005  Department of Computer & Information Science Goals By the end of this lecture you should … Understand what purpose a variable serves.Understand what purpose a variable serves. Understand primitive and composite data types.Understand primitive and composite data types. Understand why programmers assign data types to variables.Understand why programmers assign data types to variables.

Copyright ©2005  Department of Computer & Information Science Review: IPO INPUT: Gathering the necessary data that we need to produce viable information in our application.INPUT: Gathering the necessary data that we need to produce viable information in our application. PROCESSING: Manipulating that data.PROCESSING: Manipulating that data. OUTPUT: Giving back meaningful information back to our user.OUTPUT: Giving back meaningful information back to our user. Where do we store gathered data?Where do we store gathered data?

Copyright ©2005  Department of Computer & Information Science Variables We must store any data that we collect or process in memory. One of the data structures in which we store data is called a variable.We must store any data that we collect or process in memory. One of the data structures in which we store data is called a variable. A variable is a place in a computer's memory that can store a single value at any one time.A variable is a place in a computer's memory that can store a single value at any one time.

Copyright ©2005  Department of Computer & Information Science Variables vs. Constants We when store a value using a variable, we expect that value can, and often does, change.We when store a value using a variable, we expect that value can, and often does, change. We can also define a constant data structure whereby we expect the value to be static through the course of an application's run.We can also define a constant data structure whereby we expect the value to be static through the course of an application's run.

Copyright ©2005  Department of Computer & Information Science Reserving Memory When we want to reserve a spot in memory for a variable, we declare a variable.When we want to reserve a spot in memory for a variable, we declare a variable. When declaring a variable, we also need to identify that variable's data type …When declaring a variable, we also need to identify that variable's data type …

Copyright ©2005  Department of Computer & Information Science Declaring Data Type When we declare a data type, we specify which values a variable will hold.When we declare a data type, we specify which values a variable will hold. In JavaScript, we can declare primitive data types or composite data types.In JavaScript, we can declare primitive data types or composite data types.

Copyright ©2005  Department of Computer & Information Science Primitive Data Types Primitive data types serve as the building blocks for JavaScript.Primitive data types serve as the building blocks for JavaScript. There are three primitive data types:There are three primitive data types: –Number data type –String data type –Boolean data type

Copyright ©2005  Department of Computer & Information Science Composite Data Types Composite data types are derived from other types (many times, primitive types).Composite data types are derived from other types (many times, primitive types). JavaScript also includes some pre- defined composite data types, like the object data type and the array data type.JavaScript also includes some pre- defined composite data types, like the object data type and the array data type.

Copyright ©2005  Department of Computer & Information Science Why do we type? We declare data types in order to conserve resources. We only ask for the memory space that we need. For instance, if we only need enough memory to store a Boolean value, there is no sense to ask for enough memory to store a number type.We declare data types in order to conserve resources. We only ask for the memory space that we need. For instance, if we only need enough memory to store a Boolean value, there is no sense to ask for enough memory to store a number type.

Copyright ©2005  Department of Computer & Information Science Summary Variables are data structures that represent a place in a computer’s memory that hold a single value at any one time.Variables are data structures that represent a place in a computer’s memory that hold a single value at any one time. The value of a variable can, and often does, change.The value of a variable can, and often does, change. continued …

Copyright ©2005  Department of Computer & Information Science Summary A data type specifies which values a variable can hold.A data type specifies which values a variable can hold. Primitive data types are the building blocks of a language. Composite data types are complex data types derived from primitives.Primitive data types are the building blocks of a language. Composite data types are complex data types derived from primitives.