CISC105 – General Computer Science Class 9 – 07/03/2006.

Slides:



Advertisements
Similar presentations
COMP2130 Winter 2015 Storing signed numbers in memory.
Advertisements

1 C++ Syntax and Semantics The Development Process.
Lecture - 2 Number systems and computer data formats
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
Data Types H&K Chapter 7 Instructor – Gokcen Cilingir Cpt S 121 (July 12, 2011) Washington State University.
Types and Variables. Computer Programming 2 C++ in one page!
Sizes of simple data types sizeof(char) = 1 size(short) = 2 sizeof(int) = 4 size(long) = 8 sizeof(char) = 1 size(short) = 2 sizeof(int) = 2 size(long)
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Fundamentals of Strings and Characters Characters.
Computer Science 1620 Other Data Types. Quick Review: checklist for performing user input: 1) Be sure variable is declared 2) Prompt the user for input.
Lab 10 rRepresentation And Conversion of Numeric Types l Difference between Numeric Types l Automatic conversion of Data types l Explicit Conversion of.
1 Fundamental Data Types. 2 Declaration All variables must be declared before being used. –Tells the compiler to set aside an appropriate amount of space.
Basic C Programming Data Types and Arithmetic Operations 01/30/15.
1 CSC 1401 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Introduction.
0 Chap. 2. Types, Operators, and Expressions 2.1Variable Names 2.2Data Types and Sizes 2.3Constants 2.4Declarations Imperative Programming, B. Hirsbrunner,
Variables and constants Applications of Computer Programming in Earth Sciences Instructor: Dr. Cheng-Chien LiuCheng-Chien Liu Department of Earth Sciences.
Representation and Conversion of Numeric Types 4 We have seen multiple data types that C provides for numbers: int and double 4 What differences are there.
Floating Point Numbers.  Floating point numbers are real numbers.  In Java, this just means any numbers that aren’t integers (whole numbers)  For example…
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Integer Data representation Addition and Multiplication.
Simple Data Type Representation and conversion of numbers
Chapter 2: C Fundamentals Dr. Ameer Ali. Overview C Character set Identifiers and Keywords Data Types Constants Variables and Arrays Declarations Expressions.
Chapter 7 Simple Date Types Instructor: Kun-Mao Chao ( 台大資工 趙坤茂 )
Computer Science 111 Fundamentals of Programming I Number Systems.
Number Systems Spring Semester 2013Programming and Data Structure1.
Binary, Decimal and Hexadecimal Numbers Svetlin Nakov Telerik Corporation
C Tokens Identifiers Keywords Constants Operators Special symbols.
Chapter 7 Simple Date Types J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National Taipei University.
COMP 116: Introduction to Scientific Programming Lecture 28: Data types.
Data Representation - Part II. Characters A variable may not be a non-numerical type Character is the most common non- numerical type in a programming.
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.
GUIDED BY- A.S.MODI MADE BY- 1. SHWETA ALWANI 2. PRIYANKA.
Java Simple Types CSIS 3701: Advanced Object Oriented Programming.
The Teacher CP4 Binary and all that… CP4 Revision.
Unit 3 Lesson 4 How Data Types Affect Calculations Dave Clausen La Cañada High School.
1 Number Systems Lecture 10 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
ISBN Chapter 6 Data Types Introduction Primitive Data Types User-Defined Ordinal Types.
Data Type. Syntax Rules Recap keywords breakdoubleifsizeofvoid caseelseintstatic..... Identifiers not#me123th scanfprintf _idso_am_igedd007 Constant ‘a’‘+’
Copyright © – Curt Hill Types What they do.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Chapter 7 C supports two fundamentally different kinds of numeric types: (a) integer types - whole numbers (1) signed (2) unsigned (b) floating types –
Road map char data type Reading –Liang 5: Chapter 2: 2.7.4; 2.9; –Liang 6: Chapter 2: 2.7.4; 2.9 –Liang 7: Chapter 2: 2.7.4; 2.9.
Number Representation Lecture Topics How are numeric data items actually stored in computer memory? How much space (memory locations) is.
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.
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.
Characters and Strings
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
COMPUTER SCIENCE Data Representation and Machine Concepts Section 1.7 Instructor: Lin Chen Sept 2013.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
1 Scalar and composite data Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Scalar and composite data Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
C LANGUAGE UNIT 3. UNIT 3 Arrays Arrays – The concept of array – Defining arrays – Initializing arrays.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Floating Point Numbers
Nat 4/5 Computing Science Lesson 1: Binary
Fundamentals of Computer Science
Tokens in C Keywords Identifiers Constants
EPSII 59:006 Spring 2004.
Fundamental Data Types
Conversions of the type of the value of an expression
Introduction to Abstract Data Types
Simple Data Types and Function Calls
Lectures on Numerical Methods
Chapter 7 Simple Date Types Dr. Jiung-yao Huang Dept. Comm. Eng.
Numbers representations
Fundamental Data Types
COMS 161 Introduction to Computing
Variables and Constants
Section 6 Primitive Data Types
Presentation transcript:

CISC105 – General Computer Science Class 9 – 07/03/2006

Numeric Data Types Integer can be represented by various data types in C and are stored as binary values –int (16 bits – 15 bits for value 1 for sign): -32,767 to 32,767 –unsigned (16 bits): 0 to 65,535 –long (32 bits – 31 for value, 1 for sign): -2,147,483,647 to 2,147,483,647 –unsigned long (32 bits): 0 to 4,294,967,295

Numeric Data Types Floating-point Types are stored in memory by using a mantissa and exponent value such that real_number = mantissa x 2 exponent –float : to with 6 significant digits –double : to with 15 significant digits –long double : to with 19 significant digits –See doublePrecision.c doublePrecision2.cdoublePrecision.cdoublePrecision2.c

Automatic Data Type Conversion int + double; returns a double double = int; the int is converted to a double int = double; the double is converted to an int and the fractional part is lost See datatypeConversion.cdatatypeConversion.c

Explicit Type Cast You can explicitly cast data types as well. See typecast.ctypecast.c

Character Types The char data type can be represented as a character or by it’s ASCII numeric value. See printASCII.cprintASCII.c

Enumerated Types An enumerated type is a list of values that is specified by the programmer in type declaration Enumeration constant is an identifier that is one of the values of the enumerated type. See enumeratedTypes.cenumeratedTypes.c

Arrays An array is a collection of values of the same type. An array is a Data Structure –Data Structure – is a composite of related data items stored under the same name

Declaring Arrays An Array is declared by listing the type variable_name[number_of_elements] –int grades[5]; –double income_for_month[12]; –char name[15];

Accessing Elements To access the elements in an array you use the array name and the subscript –grade[1]; –income_for_month[5]; –See array1.c array2.carray1.carray2.c