Data Types Copyright © 2006 Patrick McDermott College of Alameda

Slides:



Advertisements
Similar presentations
Chapter 3 DATA: TYPES, CLASSES, AND OBJECTS. Chapter 3 Data Abstraction Abstract data types allow you to work with data without concern for how the data.
Advertisements

Java Syntax Part I Comments Identifiers Primitive Data Types Assignment.
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
Data Types and Expressions
Types and Variables. Computer Programming 2 C++ in one page!
CIS 234: Using Data in Java Thanks to Dr. Ralph D. Westfall.
1 9/10/07CS150 Introduction to Computer Science 1 Data Types Section 2.7 – 2.12 CS 150 Introduction to Computer Science I.
Structure of a C program
1 9/8/08CS150 Introduction to Computer Science 1 Data Types Section 2.7 – 2.12 CS 150 Introduction to Computer Science I.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 27, 2005.
CS150 Introduction to Computer Science 1
Chapter 2: C Fundamentals Dr. Ameer Ali. Overview C Character set Identifiers and Keywords Data Types Constants Variables and Arrays Declarations Expressions.
Java Building Elements Lecture 2 Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University
Variables and Data Types
Input & Output: Console
Copyright © 2002 W. A. Tucker1 Chapter 7 Lecture Notes Bill Tucker Austin Community College COSC 1315.
C Tokens Identifiers Keywords Constants Operators Special symbols.
1 Do you have a CS account? Primitive types –“ building blocks ” for more complicated types Java is strongly typed –All variables in a Java program must.
Access Data Types Copyright © 2006 Patrick McDermott College of Alameda
CPS120: Introduction to Computer Science
Lecture #5 Introduction to C++
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
CISC105 – General Computer Science Class 9 – 07/03/2006.
GUIDED BY- A.S.MODI MADE BY- 1. SHWETA ALWANI 2. PRIYANKA.
Primitive Variables.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs.
 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 the.
Computer Engineering 1 st Semester Dr. Rabie A. Ramadan 3.
Primitive Variables.
CONSTANTS Constants are also known as literals in C. Constants are quantities whose values do not change during program execution. There are two types.
Copyright Curt Hill Variables What are they? Why do we need them?
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
Java Language Basics By Keywords Keywords of Java are given below – abstract continue for new switch assert *** default goto * package.
Copyright © – Curt Hill Types What they do.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
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.
CSI 3125, Preliminaries, page 1 Data Type, Variables.
1.2 Primitive Data Types and Variables
CPS120: Introduction to Computer Science Variables and Constants.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
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.
0 Chap.2. Types, Operators, and Expressions 2.1Variable Names 2.2Data Types and Sizes 2.3Constants 2.4Declarations 2.5Arithmetic Operators 2.6Relational.
Types Chapter 2. C++ An Introduction to Computing, 3rd ed. 2 Objectives Observe types provided by C++ Literals of these types Explain syntax rules for.
Types Chapter 2. C++ An Introduction to Computing, 3rd ed. 2 Objectives Observe types provided by C++ Literals of these types Explain syntax rules for.
 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 Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
CSE 110: Programming Language I Matin Saad Abdullah UB 1222.
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 ENERGY 211 / CME 211 Lecture 3 September 26, 2008.
Fundamentals 2.
Asst.Prof.Dr. Tayfun ÖZGÜR
Topic 2 Elementary Programming
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
User Interaction and Variables
BASIC ELEMENTS OF A COMPUTER PROGRAM
Data Types, Arithmetic Operations
Data Types The type states how much and what kind of data the variable can store. integers- whole numbers no fractional parts int, short, long floating.
Chapter 2 Variables.
C++ Data Types Data Type
Chapter 2: Java Fundamentals
Chapter # 2 Part 2 Programs And data
Chapter 2: Java Fundamentals
C Language B. DHIVYA 17PCA140 II MCA.
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Variables and Constants
Presentation transcript:

Data Types Copyright © 2006 Patrick McDermott College of Alameda

Fact  CRC Cards : (Attribute)  ERD : Attribute  Relational : Attribute  Database : Column  Programmer : Variable  UML : Property  Etc., etc., etc. …: Field, Item, Element

The Rules C++ Allowed/Forbidden characters –Letters, Numerals, _ –NO Spaces Break_character: Underscore _ –No initial numeral Length, Very Long Case SeNsItiVe Cannot be a Keyword (Keywords are Reserved Words)  Nouns for Variables/Classes  Verbs for Functions/Methods

The Rules Java Allowed/Forbidden characters –Letters, Numerals, $, _ –NO Spaces Break_character: Underscore _ –No initial numeral Length, Very Long Case SeNsItiVe Cannot be a Keyword (Keywords are Reserved Words)  Nouns for Variables/Classes  Verbs for Functions/Methods

Numbers, Text & Truth Numbers –int or double Text –char or string –C#: char is 2 bytes in C++ wchar_t Booleans –Logical: true or false. We might not have beauty, but it does have truth. Decimal (.NET) –± $792,281,625,142,643,375,935,439,503.35m –± 79,228,162,514,264,337,593,543,950,335M

2 Kinds of Numbers Integers int A counting number A whole number Discrete No fraction No decimal Floating Point float, but use double A measuring number A fractional number Continuous Fraction Decimal 2½, , too!

Numbers Integers: 4 billion –2,147,483,648 to +2,147,483, billion if unsigned Not enough bils for Bill’s fortune Double-Precision Floating-Point: double –Range: Big enough You can enumerate all the atoms in the Universe. –Precision: at least 15 decimal digits Just enough for $Trillion to the cent. $1,234,567,890, Not quite enough for a credit card number

I Declare! String s; String s = "Hi"; int x = 0; double x, y; int x = 0, y = 1; final int MYNUMBER = 0; The Unchanging const ant ALLUPPERCASE or ALL_UPPER_CASE

I Declare! string s; string s = "Hi"; int x = 0; double x, y; int x = 0, y = 1; const int MYNUMBER = 0; The Unchanging const ant ALLUPPERCASE or ALL_UPPER_CASE extern int SOMEWHERE_NOT_HERE; In compliment extern, ’tis not long after But I will wear my heart upon my sleeve—Iago, Otello I.1.

Number versus Character Sort As numbers, one & two & three are binary 1 and 10 and 11. As text, 1 & 2 & 3 are ASCII characters 49 & 50 & 51. Numbers sort by value. Text sorts character by character. You can be richer than Bill Gates! As text, $9 is greater than $80,000,000,000! So, just keep $9, and sort net worth as text!

Precision Values of type float have seven digits of precision. Values of type double have digits of precision. Values of type decimal are represented as integer values that are scaled by a power of 10. Values between -1.0 and 1.0 are represented exactly to 28 digits.

Size not Standard Each computer system is different. Types are based on the system Word. We are on a 32-bit (4-byte) system, So int is a word (4 bytes), double is 2 words (8 bytes)… TypeSize char, unsigned char, signed char 1 byte short, unsigned short 2 bytes int, unsigned int 4 bytes long, unsigned long 4 bytes float 4 bytes double 8 bytes long double 8 bytes

The incredible Growing int Windows 3.11 (and earlier) The 16-bit Windows A 2-byte system word Windows 95 (and later) The 32-bit Windows A 4-byte system DWord C Standard for int : The short must not be longer than the int The long must not be shorter than the int short int long short int long Windows 7 & Java (and later) The 64-bit Windows A 8-byte system QWord short int long

Alphanumeric Text String s Single character or a string of characters? 'a' is the single character known as a "a" is a character string consisting of the letter a A C string is actually a null-terminated array It needs a space for the null (binary zeroes) "a" is 2 characters long: a + null lpsz “long pointer to a null-terminated string” [yuck!] String Theory Strings have been a sore point, with me & others Unnecessarily overcomplicated What were they thinking???