SlideShare a Scribd company logo
DATA TYPES
Lesson 8
MANOLO L. GIRON
RMTU
1Structure of Programming Language
DATA TYPES
• A data type defines a collection of data values and a set of
predefined operations on those values.
• Computer programs produce results by manipulating data.
• An important factor in determining the ease with which they
can perform this task is how well the data types available in
the language being used match the objects in the real-world
of the problem being addressed.
2Structure of Programming Language
Numeric Data Types
• Integer
• The most common primitive numeric data type.
• These sizes of integers, and often a few others, are supported by some programming
languages.
• Java includes four signed integer sizes: byte, short, int, and long.
• C++ and C#, include unsigned integer types, which are simply types for integer values
without signs.
• Unsigned types are often used for binary data.
• Signed integer value is represented in a computer by a string of bits, with one of the bits
(typically the leftmost) representing the sign.
3Structure of Programming Language
Numeric Data Types cont.
• Floating-Point
• Floating-point data types model real numbers, but the representations are only approximations
for many real values.
• On most computers, floating point numbers are stored in binary, which exacerbates the problem.
• Floating-point values are represented as fractions and exponents, a form that is borrowed from
scientific notation.
• Most languages include two floating-point types, often called float and double
• The float type is the standard size, usually being stored in four bytes of memory.
• The double type
• is provided for situations where larger fractional parts and/or a larger range of exponents is needed.
• Double-precision variables usually occupy twice as
• much storage as float variables and provide at least twice the number of bits of fraction.
4Structure of Programming Language
Numeric Data Types Cont.
• Decimal
• Decimal data types store a fixed number of decimal digits, with the decimal point at a
fixed position in the value.
• Decimal types have the advantage of being able to precisely store decimal values, at
least those within a restricted range, which cannot be done with floating-point.
• Decimal types are stored very much like character strings, using binary codes for the
decimal digits.
• These are the primary data types for business data processing and are therefore essential
to COBOL. C# and F# also have decimal data types.
5Structure of Programming Language
Numeric Data Types Cont.
• Complex
• Complex values are represented as ordered pairs of floating-point values.
• Some programming languages support a complex data type—for example, Fortran and
Python.
• In Python, the imaginary part of a complex literal is specified by following it with a j or
J—for example, (7 + 3j)
6Structure of Programming Language
Boolean Data Types
• Boolean types are perhaps the simplest of all types.
• Their range of values
• has only two elements: one for TRUE and one for FALSE.
• Boolean types are often used to represent switches or flags in programs.
7Structure of Programming Language
Character Types Data Types
• A character string type is one in which the values consist of sequences of
characters.
• Character string constants are used to label output, and the input and output of all
kinds of data are often done in terms of strings.
• Character string constants are used to label output, and the input and output of all
kinds of data are often done in terms of strings.
• The most common string operations are assignment, catenation, substring
reference, comparison, and pattern matching.
• C and C++ use char arrays to store character strings.
• C++ programmers should use the string class from the standard library, rather than
char arrays and the C string library.
• C# and Ruby include string classes that are similar to those of Java
8Structure of Programming Language
User-Defined Ordinal Data Types
• Enumeration Types
• An enumeration type is one in which all of the possible values, which are named constants, are
provided, or enumerated, in the definition.
• Enumeration types provide a way of defining and grouping collections of named constants, which are
called enumeration constants.
• C# example: enumdays {Mon, Tue, Wed, Thu, Fri, Sat, Sun};
• C and Pascal were the first widely used languages to include an enumeration data type. C++ includes
C’s enumeration types. In C++, we could have the following:
• enumcolors {red, blue, green, yellow, black};
• colors myColor = blue, yourColor = red;
• In ML, enumeration types are defined as new types with datatypedeclarations. For example, we could
have the following:
• datatypeweekdays = Monday | Tuesday | Wednesday | Thursday | Friday 9Structure of Programming Language
Array Data Types
• An array is a homogeneous aggregate of data elements in which an individual
element is identified by its position in the aggregate, relative to the first element.
• In many languages, such as C, C++, Java, Ada, and C#, all of the elements of an
array are required to be of the same type.
• STATIC ARRAY
• FIXED STACK-DYNAMIC ARRAY
• STACK-DYNAMIC ARRAY
• FIXED HEAP-DYNAMIC ARRAY
• HEAP-DYNAMIC ARRAY
10Structure of Programming Language
STATIC ARRAY
• A static array is one in which the subscript ranges are statically bound and
storage allocation is static (done before run time).
• The advantage of static arrays is efficiency:
• No dynamic allocation or de allocation is required.
• The disadvantage is that the storage for the array is fixed for the entire
execution time of the program
11Structure of Programming Language
FIXED STACK-DYNAMIC ARRAY
• A fixed stack-dynamic array is one in which the subscript ranges are statically
bound, but the allocation is done at declaration elaboration time during execution.
• The advantage of fixed stack-dynamic arrays over static arrays is space efficiency.
• A large array in one subprogram can use the same space as a large array in a
different subprogram, as long as both subprograms are not active at the same time.
• The same is true if the two arrays are in different blocks that are not active at the
same time. The disadvantage is the required allocation and de allocation time.
12Structure of Programming Language
STACK-DYNAMIC ARRAY
• A stack-dynamic array is one in which both the subscript ranges and the
storage allocation are dynamically bound at elaboration time.
• Once the subscript ranges are bound and the storage is allocated, however,
they remain fixed during the lifetime of the variable.
• The advantage of stack-dynamic arrays over static and fixed stack-dynamic
arrays is flexibility.
• The size of an array need not be known until the array is about to be used.
13Structure of Programming Language
FIXED HEAP-DYNAMIC ARRAY
• A fixed heap-dynamic array is similar to a fixed stack-dynamic array, in that the
subscript ranges and the storage binding are both fixed after storage is allocated.
• The differences are that both the subscript ranges and storage bindings are done
when the user program requests them during execution, and the storage is allocated
from the heap, rather than the stack.
• The advantage of fixed heap-dynamic arrays is flexibility—the array’s size always fits
the problem.
• The disadvantage is allocation time from the heap, which is longer than allocation
time from the stack.
14Structure of Programming Language
HEAP-DYNAMIC ARRAY
• A heap-dynamic array is one in which the binding of subscript ranges and
storage allocation is dynamic and can change any number of times during the
array’s lifetime.
• The advantage of heap-dynamic arrays over the others is flexibility: Arrays
can grow and shrink during program execution as the need for space
changes.
• The disadvantage is that allocation and de allocation take longer and may
happen many times during execution of the program.
15Structure of Programming Language
REFERENCES
• CONCEPTS OF
PROGRAMMING LANGUAGES
TENTH EDITION
ROBERT W. SEBESTA
Structure of Programming Language

More Related Content

What's hot

Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
Akhil Kaushik
 
Programming languages and concepts by vivek parihar
Programming languages and concepts by vivek pariharProgramming languages and concepts by vivek parihar
Programming languages and concepts by vivek parihar
Vivek Parihar
 
Software maintenance Unit5
Software maintenance  Unit5Software maintenance  Unit5
Software maintenance Unit5
Mohammad Faizan
 
Fundamentals of OOP (Object Oriented Programming)
Fundamentals of OOP (Object Oriented Programming)Fundamentals of OOP (Object Oriented Programming)
Fundamentals of OOP (Object Oriented Programming)
MD Sulaiman
 
Storage classes in c++
Storage classes in c++Storage classes in c++
Storage classes in c++
Jaspal Singh
 
REQUIREMENT ENGINEERING
REQUIREMENT ENGINEERINGREQUIREMENT ENGINEERING
REQUIREMENT ENGINEERING
Saqib Raza
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
Tanzeela_Hussain
 
Classes and Objects
Classes and Objects  Classes and Objects
Classes and Objects
yndaravind
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
javaTpoint s
 
Introduction to object oriented programming
Introduction to object oriented programmingIntroduction to object oriented programming
Introduction to object oriented programmingAbzetdin Adamov
 
Type Conversion, Precedence and Associativity
Type Conversion, Precedence and AssociativityType Conversion, Precedence and Associativity
Type Conversion, Precedence and Associativity
Aakash Singh
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)Jay Patel
 
Master theorem
Master theoremMaster theorem
Master theorem
fika sweety
 
Design concepts and design principles
Design concepts and design principlesDesign concepts and design principles
Design concepts and design principles
Dhruvin Nakrani
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
Hawkman Academy
 
1. over view and history of c
1. over view and history of c1. over view and history of c
1. over view and history of cHarish Kumawat
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
Sarmad Ali
 
Assembly and Machine Code
Assembly and Machine CodeAssembly and Machine Code
Assembly and Machine Code
Project Student
 

What's hot (20)

Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Programming languages and concepts by vivek parihar
Programming languages and concepts by vivek pariharProgramming languages and concepts by vivek parihar
Programming languages and concepts by vivek parihar
 
Software maintenance Unit5
Software maintenance  Unit5Software maintenance  Unit5
Software maintenance Unit5
 
Fundamentals of OOP (Object Oriented Programming)
Fundamentals of OOP (Object Oriented Programming)Fundamentals of OOP (Object Oriented Programming)
Fundamentals of OOP (Object Oriented Programming)
 
Storage classes in c++
Storage classes in c++Storage classes in c++
Storage classes in c++
 
REQUIREMENT ENGINEERING
REQUIREMENT ENGINEERINGREQUIREMENT ENGINEERING
REQUIREMENT ENGINEERING
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
Classes and Objects
Classes and Objects  Classes and Objects
Classes and Objects
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 
Introduction to object oriented programming
Introduction to object oriented programmingIntroduction to object oriented programming
Introduction to object oriented programming
 
Type Conversion, Precedence and Associativity
Type Conversion, Precedence and AssociativityType Conversion, Precedence and Associativity
Type Conversion, Precedence and Associativity
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)
 
Ooad
OoadOoad
Ooad
 
Master theorem
Master theoremMaster theorem
Master theorem
 
Design concepts and design principles
Design concepts and design principlesDesign concepts and design principles
Design concepts and design principles
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
 
1. over view and history of c
1. over view and history of c1. over view and history of c
1. over view and history of c
 
C#.NET
C#.NETC#.NET
C#.NET
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
 
Assembly and Machine Code
Assembly and Machine CodeAssembly and Machine Code
Assembly and Machine Code
 

Similar to 8. data types

Java platform
Java platformJava platform
Java platform
Visithan
 
Datatype
DatatypeDatatype
Datatype
baran19901990
 
pl12ch6.ppt
pl12ch6.pptpl12ch6.ppt
pl12ch6.ppt
BrandonGarcia294013
 
332 ch07
332 ch07332 ch07
332 ch07YaQ10
 
C language
C languageC language
C language
Rupanshi rawat
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
Ahmed Raza
 
chapter 5.ppt
chapter 5.pptchapter 5.ppt
chapter 5.ppt
ThedronBerhanu
 
Data structure & Algorithms - Programming in C
Data structure & Algorithms - Programming in CData structure & Algorithms - Programming in C
Data structure & Algorithms - Programming in C
babuk110
 
Ch6
Ch6Ch6
CS4443 - Modern Programming Language - I Lecture (2)
CS4443 - Modern Programming Language - I  Lecture (2)CS4443 - Modern Programming Language - I  Lecture (2)
CS4443 - Modern Programming Language - I Lecture (2)
Dilawar Khan
 
6 data types
6 data types6 data types
6 data types
Munawar Ahmed
 
Data.ppt
Data.pptData.ppt
Data.ppt
RithikRaj25
 
12.6-12.9.pptx
12.6-12.9.pptx12.6-12.9.pptx
12.6-12.9.pptx
WinterSnow16
 
INTRODUCTION TO C PROGRAMMING in basic c language
INTRODUCTION TO C PROGRAMMING in basic c languageINTRODUCTION TO C PROGRAMMING in basic c language
INTRODUCTION TO C PROGRAMMING in basic c language
GOKULKANNANMMECLECTC
 
C programmimng basic.ppt
C programmimng basic.pptC programmimng basic.ppt
C programmimng basic.ppt
ASIT Education
 
C programming
C programmingC programming
C programming
KarthicaMarasamy
 
Java introduction
Java introductionJava introduction
Java introduction
GaneshKumarKanthiah
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
Mahfuzur Rahman
 
Algorithms-Flowcharts-Data-Types-and-Pseudocodes.pptx
Algorithms-Flowcharts-Data-Types-and-Pseudocodes.pptxAlgorithms-Flowcharts-Data-Types-and-Pseudocodes.pptx
Algorithms-Flowcharts-Data-Types-and-Pseudocodes.pptx
RobertCarreonBula
 

Similar to 8. data types (20)

Java platform
Java platformJava platform
Java platform
 
Datatype
DatatypeDatatype
Datatype
 
pl12ch6.ppt
pl12ch6.pptpl12ch6.ppt
pl12ch6.ppt
 
332 ch07
332 ch07332 ch07
332 ch07
 
C language
C languageC language
C language
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
chapter 5.ppt
chapter 5.pptchapter 5.ppt
chapter 5.ppt
 
Data structure & Algorithms - Programming in C
Data structure & Algorithms - Programming in CData structure & Algorithms - Programming in C
Data structure & Algorithms - Programming in C
 
Ch6
Ch6Ch6
Ch6
 
CS4443 - Modern Programming Language - I Lecture (2)
CS4443 - Modern Programming Language - I  Lecture (2)CS4443 - Modern Programming Language - I  Lecture (2)
CS4443 - Modern Programming Language - I Lecture (2)
 
6 data types
6 data types6 data types
6 data types
 
Data.ppt
Data.pptData.ppt
Data.ppt
 
12.6-12.9.pptx
12.6-12.9.pptx12.6-12.9.pptx
12.6-12.9.pptx
 
INTRODUCTION TO C PROGRAMMING in basic c language
INTRODUCTION TO C PROGRAMMING in basic c languageINTRODUCTION TO C PROGRAMMING in basic c language
INTRODUCTION TO C PROGRAMMING in basic c language
 
C programmimng basic.ppt
C programmimng basic.pptC programmimng basic.ppt
C programmimng basic.ppt
 
C programming
C programmingC programming
C programming
 
Java introduction
Java introductionJava introduction
Java introduction
 
c++
 c++  c++
c++
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Algorithms-Flowcharts-Data-Types-and-Pseudocodes.pptx
Algorithms-Flowcharts-Data-Types-and-Pseudocodes.pptxAlgorithms-Flowcharts-Data-Types-and-Pseudocodes.pptx
Algorithms-Flowcharts-Data-Types-and-Pseudocodes.pptx
 

More from Zambales National High School

8. digital integrated circuit
8. digital integrated circuit8. digital integrated circuit
8. digital integrated circuit
Zambales National High School
 
7. transformer and diode
7. transformer and diode7. transformer and diode
7. transformer and diode
Zambales National High School
 
5. resistor and capacitor application
5. resistor and capacitor application5. resistor and capacitor application
5. resistor and capacitor application
Zambales National High School
 
6. transistor
6. transistor6. transistor
4. resistor and capacitor
4. resistor and capacitor4. resistor and capacitor
4. resistor and capacitor
Zambales National High School
 
2. Basic Electronics Circuit
2. Basic Electronics Circuit2. Basic Electronics Circuit
2. Basic Electronics Circuit
Zambales National High School
 
3. basic electrical and electronic symbol
3. basic electrical and electronic symbol3. basic electrical and electronic symbol
3. basic electrical and electronic symbol
Zambales National High School
 
11. abstraction and capsulation
11. abstraction and capsulation11. abstraction and capsulation
11. abstraction and capsulation
Zambales National High School
 
10. sub program
10. sub program10. sub program
9. control statement
9. control statement9. control statement
9. control statement
Zambales National High School
 
7. name binding and scopes
7. name binding and scopes7. name binding and scopes
7. name binding and scopes
Zambales National High School
 
6. describing syntax and semantics
6. describing syntax and semantics6. describing syntax and semantics
6. describing syntax and semantics
Zambales National High School
 
5. evolution
5. evolution5. evolution
4. processor
4. processor4. processor
3. criteria
3. criteria3. criteria
2. pl domain
2. pl domain2. pl domain
1. reason why study spl
1. reason why study spl1. reason why study spl
1. reason why study spl
Zambales National High School
 
18. the components of the system unit
18. the components of the system unit18. the components of the system unit
18. the components of the system unit
Zambales National High School
 
17. software for home, personal, and educational
17. software for home, personal, and educational17. software for home, personal, and educational
17. software for home, personal, and educational
Zambales National High School
 
16. graphics and multimedia software
16. graphics and multimedia software16. graphics and multimedia software
16. graphics and multimedia software
Zambales National High School
 

More from Zambales National High School (20)

8. digital integrated circuit
8. digital integrated circuit8. digital integrated circuit
8. digital integrated circuit
 
7. transformer and diode
7. transformer and diode7. transformer and diode
7. transformer and diode
 
5. resistor and capacitor application
5. resistor and capacitor application5. resistor and capacitor application
5. resistor and capacitor application
 
6. transistor
6. transistor6. transistor
6. transistor
 
4. resistor and capacitor
4. resistor and capacitor4. resistor and capacitor
4. resistor and capacitor
 
2. Basic Electronics Circuit
2. Basic Electronics Circuit2. Basic Electronics Circuit
2. Basic Electronics Circuit
 
3. basic electrical and electronic symbol
3. basic electrical and electronic symbol3. basic electrical and electronic symbol
3. basic electrical and electronic symbol
 
11. abstraction and capsulation
11. abstraction and capsulation11. abstraction and capsulation
11. abstraction and capsulation
 
10. sub program
10. sub program10. sub program
10. sub program
 
9. control statement
9. control statement9. control statement
9. control statement
 
7. name binding and scopes
7. name binding and scopes7. name binding and scopes
7. name binding and scopes
 
6. describing syntax and semantics
6. describing syntax and semantics6. describing syntax and semantics
6. describing syntax and semantics
 
5. evolution
5. evolution5. evolution
5. evolution
 
4. processor
4. processor4. processor
4. processor
 
3. criteria
3. criteria3. criteria
3. criteria
 
2. pl domain
2. pl domain2. pl domain
2. pl domain
 
1. reason why study spl
1. reason why study spl1. reason why study spl
1. reason why study spl
 
18. the components of the system unit
18. the components of the system unit18. the components of the system unit
18. the components of the system unit
 
17. software for home, personal, and educational
17. software for home, personal, and educational17. software for home, personal, and educational
17. software for home, personal, and educational
 
16. graphics and multimedia software
16. graphics and multimedia software16. graphics and multimedia software
16. graphics and multimedia software
 

Recently uploaded

A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 

Recently uploaded (20)

A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 

8. data types

  • 1. DATA TYPES Lesson 8 MANOLO L. GIRON RMTU 1Structure of Programming Language
  • 2. DATA TYPES • A data type defines a collection of data values and a set of predefined operations on those values. • Computer programs produce results by manipulating data. • An important factor in determining the ease with which they can perform this task is how well the data types available in the language being used match the objects in the real-world of the problem being addressed. 2Structure of Programming Language
  • 3. Numeric Data Types • Integer • The most common primitive numeric data type. • These sizes of integers, and often a few others, are supported by some programming languages. • Java includes four signed integer sizes: byte, short, int, and long. • C++ and C#, include unsigned integer types, which are simply types for integer values without signs. • Unsigned types are often used for binary data. • Signed integer value is represented in a computer by a string of bits, with one of the bits (typically the leftmost) representing the sign. 3Structure of Programming Language
  • 4. Numeric Data Types cont. • Floating-Point • Floating-point data types model real numbers, but the representations are only approximations for many real values. • On most computers, floating point numbers are stored in binary, which exacerbates the problem. • Floating-point values are represented as fractions and exponents, a form that is borrowed from scientific notation. • Most languages include two floating-point types, often called float and double • The float type is the standard size, usually being stored in four bytes of memory. • The double type • is provided for situations where larger fractional parts and/or a larger range of exponents is needed. • Double-precision variables usually occupy twice as • much storage as float variables and provide at least twice the number of bits of fraction. 4Structure of Programming Language
  • 5. Numeric Data Types Cont. • Decimal • Decimal data types store a fixed number of decimal digits, with the decimal point at a fixed position in the value. • Decimal types have the advantage of being able to precisely store decimal values, at least those within a restricted range, which cannot be done with floating-point. • Decimal types are stored very much like character strings, using binary codes for the decimal digits. • These are the primary data types for business data processing and are therefore essential to COBOL. C# and F# also have decimal data types. 5Structure of Programming Language
  • 6. Numeric Data Types Cont. • Complex • Complex values are represented as ordered pairs of floating-point values. • Some programming languages support a complex data type—for example, Fortran and Python. • In Python, the imaginary part of a complex literal is specified by following it with a j or J—for example, (7 + 3j) 6Structure of Programming Language
  • 7. Boolean Data Types • Boolean types are perhaps the simplest of all types. • Their range of values • has only two elements: one for TRUE and one for FALSE. • Boolean types are often used to represent switches or flags in programs. 7Structure of Programming Language
  • 8. Character Types Data Types • A character string type is one in which the values consist of sequences of characters. • Character string constants are used to label output, and the input and output of all kinds of data are often done in terms of strings. • Character string constants are used to label output, and the input and output of all kinds of data are often done in terms of strings. • The most common string operations are assignment, catenation, substring reference, comparison, and pattern matching. • C and C++ use char arrays to store character strings. • C++ programmers should use the string class from the standard library, rather than char arrays and the C string library. • C# and Ruby include string classes that are similar to those of Java 8Structure of Programming Language
  • 9. User-Defined Ordinal Data Types • Enumeration Types • An enumeration type is one in which all of the possible values, which are named constants, are provided, or enumerated, in the definition. • Enumeration types provide a way of defining and grouping collections of named constants, which are called enumeration constants. • C# example: enumdays {Mon, Tue, Wed, Thu, Fri, Sat, Sun}; • C and Pascal were the first widely used languages to include an enumeration data type. C++ includes C’s enumeration types. In C++, we could have the following: • enumcolors {red, blue, green, yellow, black}; • colors myColor = blue, yourColor = red; • In ML, enumeration types are defined as new types with datatypedeclarations. For example, we could have the following: • datatypeweekdays = Monday | Tuesday | Wednesday | Thursday | Friday 9Structure of Programming Language
  • 10. Array Data Types • An array is a homogeneous aggregate of data elements in which an individual element is identified by its position in the aggregate, relative to the first element. • In many languages, such as C, C++, Java, Ada, and C#, all of the elements of an array are required to be of the same type. • STATIC ARRAY • FIXED STACK-DYNAMIC ARRAY • STACK-DYNAMIC ARRAY • FIXED HEAP-DYNAMIC ARRAY • HEAP-DYNAMIC ARRAY 10Structure of Programming Language
  • 11. STATIC ARRAY • A static array is one in which the subscript ranges are statically bound and storage allocation is static (done before run time). • The advantage of static arrays is efficiency: • No dynamic allocation or de allocation is required. • The disadvantage is that the storage for the array is fixed for the entire execution time of the program 11Structure of Programming Language
  • 12. FIXED STACK-DYNAMIC ARRAY • A fixed stack-dynamic array is one in which the subscript ranges are statically bound, but the allocation is done at declaration elaboration time during execution. • The advantage of fixed stack-dynamic arrays over static arrays is space efficiency. • A large array in one subprogram can use the same space as a large array in a different subprogram, as long as both subprograms are not active at the same time. • The same is true if the two arrays are in different blocks that are not active at the same time. The disadvantage is the required allocation and de allocation time. 12Structure of Programming Language
  • 13. STACK-DYNAMIC ARRAY • A stack-dynamic array is one in which both the subscript ranges and the storage allocation are dynamically bound at elaboration time. • Once the subscript ranges are bound and the storage is allocated, however, they remain fixed during the lifetime of the variable. • The advantage of stack-dynamic arrays over static and fixed stack-dynamic arrays is flexibility. • The size of an array need not be known until the array is about to be used. 13Structure of Programming Language
  • 14. FIXED HEAP-DYNAMIC ARRAY • A fixed heap-dynamic array is similar to a fixed stack-dynamic array, in that the subscript ranges and the storage binding are both fixed after storage is allocated. • The differences are that both the subscript ranges and storage bindings are done when the user program requests them during execution, and the storage is allocated from the heap, rather than the stack. • The advantage of fixed heap-dynamic arrays is flexibility—the array’s size always fits the problem. • The disadvantage is allocation time from the heap, which is longer than allocation time from the stack. 14Structure of Programming Language
  • 15. HEAP-DYNAMIC ARRAY • A heap-dynamic array is one in which the binding of subscript ranges and storage allocation is dynamic and can change any number of times during the array’s lifetime. • The advantage of heap-dynamic arrays over the others is flexibility: Arrays can grow and shrink during program execution as the need for space changes. • The disadvantage is that allocation and de allocation take longer and may happen many times during execution of the program. 15Structure of Programming Language
  • 16. REFERENCES • CONCEPTS OF PROGRAMMING LANGUAGES TENTH EDITION ROBERT W. SEBESTA Structure of Programming Language