SlideShare a Scribd company logo
1
Fundamental Data Types
http://improvec.blogspot.in
2
Declaration
• All variables must be declared before
being used.
– Tells compiler to set aside an appropriate
amount of space in memory to hold a value.
– Enables the compiler to perform operations
using the declared variables.
http://improvec.blogspot.in
3
Basic Data Types
• char character
• int integer
• float floating-point
• double double floating-point
• void valueless
http://improvec.blogspot.in
4
Modifying the Basic Types
• Type modifier:
signed unsigned long short
• When a type modifier is used by itself, then int is
assumed.
Modifier Same As
signed signed int
unsigned unsigned int
long long int
short short int
http://improvec.blogspot.in
5
Data Type char
Have Seen:Chars are treated as small integers &
conversely small ints are treated as chars.
char c = ‘a’;
printf (“%c”, c + 1) b
printf (“%d”, c + 2) 99
Each char variable stored in 1 Byte 8 Bits:
27
26
25
24
23
22
21
20
128 64 32 16 8 4 2 1
a
0000110 1http://improvec.blogspot.in
6
• String of binary digits are called bit
strings.
• A bit string is interpreted as a binary
number. bnbn-1
……
b2b1b0
0 1 1 0 0 0 0 1 a
• This bit string has the value:
1×26
+ 1×25
+ 1×20
= 97http://improvec.blogspot.in
7
3 types:
1) char 2) unsigned char 3) signed char
Each uses 1 Byte.
Signed char -128 to 127
Unsigned char 0 to 255
http://improvec.blogspot.in
8
INTEGERS : Include the natural counting
numbers and their negatives.
INTEGRAL DATA TYPES:
int short long unsigned
Data Type int
http://improvec.blogspot.in
9
• The magnitude of the number that an int
variable can hold depends on
___________?
2 Byte word ~ -32 K To +32K
-215
, …, -3, -2, -1, 0, 1, 2, 3, …, 215
-1
4 Byte word ~ -2 Billion To +2 Billion
-231
, …. -3, -2, -1, 0, 1, 2, 3, …, 231
-1
word size(bits) of the machine is machine dependent
http://improvec.blogspot.in
10
• Integer overflow:
– Value too large for defined Storage Location.
– Typically program continues to run but
incorrect results.
– The programmer must strive at all times to
avoid integer overflow.
http://improvec.blogspot.in
11
Types short, long, unsigned
• short - used where conserving storage is a
concern (usually 2 Bytes).
-32 Thousand To +32 Thousand
-215
, -215
+1, …, -3, -2, -1, 0, 1, 2, 3, …, 215
-1
• long - needed for larger integers (usually 4
bytes).
-2 Billion To +2 Billion
31 31 31
http://improvec.blogspot.in
12
• Unsigned - no sign bit, same number
bytes as int.
The range, u, of values:
0 ≤ u ≤ 2wordsize
-1
2 Byte word ~ 0 To + 64 Thousand
0, 1, 2, 3, …, 216
-1
4 Byte word ~ 0 To + 4 Billion
0, 1, 2, 3, …, 232
-1http://improvec.blogspot.in
13
Suffix:
u - 20u
l – 20l
ul - 20ul
(case not significant)
IF no suffix with constant - system will choose the
first of : int - long - unsigned long
That can hold the value.
http://improvec.blogspot.in
14
float double long double
• Suffixes for constants
f or F float 3.7 F
l or L long double 3.7 L
• Any unsuffixed floating constant is of type
double (working type).
The Floating Types
http://improvec.blogspot.in
15
• Notation: exponential or decimal
Must have Exponent or Dec pt or Both.
1.234567e5 123456.7
1.234567e-3 0.001234567
0e0 correct 0.0
.e0 wrong
May not contain any blanks or special characters.
• Typical Storage: Float < Double
http://improvec.blogspot.in
16
Precision: The number of significant decimal
digits that floating value carries.
Range: Limits of largest & smallest possible
values that can be in a variable of that
type.
Float: 4 Bytes - about 6 decimal places of
accuracy- single precision.
Double: 8 Bytes - about 15 decimal places
of accuracy- double precision.http://improvec.blogspot.in
17
Internal Representation
FLOAT:
01 8 9 31
SEEEEEEEE mmmmm…m
DOUBLE:
01 11 12 63
SEEEEEEEEEEE mmmmmmm…m
Implied mantissa of 1 is not stored.
Sign bit (1 for neg-otherwise pos).http://improvec.blogspot.in
18
Float:
Precision: 6 significant digits.
Range: 10-38
to 10+38
0.d1d2d3d4d5d6× 10n
Double:
Precision: 15 significant digits (252
≈ 1015
)
Range: 10-308
to 10+308
0.123451234512345 × 103
http://improvec.blogspot.in
19
Note:
1. Not all Real numbers are exactly
representable in binary memory.
2. Floating Arithmetic ops, unlike integer
arithmetic, may not be exact.
http://improvec.blogspot.in
20
• Unary operator used to find the number of Bytes
needed to store an object.
sizeof(object)
• Object
– Data type int , float, …
– Expression a + b
Array
Will cover
later
Structure
Compile-Time Operator sizeof
http://improvec.blogspot.in
21
Assuming that integers are 4 bytes and
doubles are 8 bytes.
double f;
printf("%d ",sizeof (f)); 8
printf(''%d", sizeof(int)); 4
http://improvec.blogspot.in
22
sizeof(char) = 1
sizeof(short) ≤ sizeof(int) ≤ sizeof(long)
sizeof(signed)=sizeof(unsigned)=sizeof(int)
sizeof(float)
<= sizeof(double )
<= sizeof( long double)
http://improvec.blogspot.in
23
Conversions
• When constants and variables of different types
are mixed in an expression, the compiler converts
all operands to the type of the largest operand-
Called Type Promotion.
- First, all char and short values are automatically
elevated to int. Called integral promotion.
- int + int = int
- short + short = int
- Arithmetic Conversion (See pg. 217)
http://improvec.blogspot.in
24
char ch;
int i;
float f;
double d,result;
result= (ch / i) + (f * d) – (f + i);
int double float
double
http://improvec.blogspot.in
25
• Casts - Explicit conversions.
(type) expression
If i is int:
(float) i will change expression value to
float, i is not changed.
Casts
(float) i/2
http://improvec.blogspot.in
26
• Apply to an Expression:
(float) (‘c’ + 3)
• Cannot apply to an Assignment:
(int) f = 3: illegal
• As an unary operator, a cast has the same
precedence as any other unary operator.
(float) i + 3 ( (float) i ) + 3
http://improvec.blogspot.in
27
/* print i and i/2 with fractions */
int main(void)
{
int i;
for(i=l; i<=100; ++i)
printf(''%d //2 is: %f
n", i, (float) i /2);
return 0;
}
http://improvec.blogspot.in
28
General forms:
(int) char expression- ordinal value of char
expression
(char) int expression- character with the
ordinal value of int
expression
(int) float expression- truncates the float
expression
(float) int expression- converts int to float
(double) float exp- converts float to
doublehttp://improvec.blogspot.in

More Related Content

What's hot

Module 00 Bitwise Operators in C
Module 00 Bitwise Operators in CModule 00 Bitwise Operators in C
Module 00 Bitwise Operators in C
Tushar B Kute
 
Using Cipher Key to Generate Dynamic S-Box in AES Cipher System
Using Cipher Key to Generate Dynamic S-Box in AES Cipher SystemUsing Cipher Key to Generate Dynamic S-Box in AES Cipher System
Using Cipher Key to Generate Dynamic S-Box in AES Cipher System
CSCJournals
 
Bitwise operators
Bitwise operatorsBitwise operators
Bitwise operators
Puneet Rajput
 
Bitwise Operations in Programming
Bitwise Operations in ProgrammingBitwise Operations in Programming
Bitwise Operations in Programming
Svetlin Nakov
 
In what way can C++0x standard help you eliminate 64-bit errors
In what way can C++0x standard help you eliminate 64-bit  errorsIn what way can C++0x standard help you eliminate 64-bit  errors
In what way can C++0x standard help you eliminate 64-bit errors
PVS-Studio
 
Aes128 bit project_report
Aes128 bit project_reportAes128 bit project_report
Aes128 bit project_report
Nikhil Gupta
 
Конверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемыеКонверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемые
Platonov Sergey
 
Parallel Adder and Subtractor
Parallel Adder and SubtractorParallel Adder and Subtractor
Parallel Adder and Subtractor
Smit Shah
 
Binary parallel adder
Binary parallel adderBinary parallel adder
Binary parallel adder
anu surya
 
Chapter 6
Chapter 6Chapter 6
Adder & subtractor (Half adder, Full adder, Half subtractor, Full subtractor)
Adder & subtractor (Half adder, Full adder, Half subtractor, Full subtractor)Adder & subtractor (Half adder, Full adder, Half subtractor, Full subtractor)
Adder & subtractor (Half adder, Full adder, Half subtractor, Full subtractor)
ISMT College
 
Chapter 03 arithmetic for computers
Chapter 03   arithmetic for computersChapter 03   arithmetic for computers
Chapter 03 arithmetic for computersBảo Hoang
 
Arithmetic Operations
Arithmetic OperationsArithmetic Operations
Arithmetic Operations
gueste99d9a
 
A (brief) overview of Span<T>
A (brief) overview of Span<T>A (brief) overview of Span<T>
A (brief) overview of Span<T>
David Wengier
 
Aes
AesAes
SunPy: Python for solar physics
SunPy: Python for solar physicsSunPy: Python for solar physics
SunPy: Python for solar physicssegfaulthunter
 
Signed Addition And Subtraction
Signed Addition And SubtractionSigned Addition And Subtraction
Signed Addition And Subtraction
Keyur Vadodariya
 
Computer Arithmetic
Computer ArithmeticComputer Arithmetic
Computer Arithmetic
Kamal Acharya
 
Csc1401 lecture03 - computer arithmetic - arithmetic and logic unit (alu)
Csc1401   lecture03 - computer arithmetic - arithmetic and logic unit (alu)Csc1401   lecture03 - computer arithmetic - arithmetic and logic unit (alu)
Csc1401 lecture03 - computer arithmetic - arithmetic and logic unit (alu)
IIUM
 

What's hot (20)

Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
 
Module 00 Bitwise Operators in C
Module 00 Bitwise Operators in CModule 00 Bitwise Operators in C
Module 00 Bitwise Operators in C
 
Using Cipher Key to Generate Dynamic S-Box in AES Cipher System
Using Cipher Key to Generate Dynamic S-Box in AES Cipher SystemUsing Cipher Key to Generate Dynamic S-Box in AES Cipher System
Using Cipher Key to Generate Dynamic S-Box in AES Cipher System
 
Bitwise operators
Bitwise operatorsBitwise operators
Bitwise operators
 
Bitwise Operations in Programming
Bitwise Operations in ProgrammingBitwise Operations in Programming
Bitwise Operations in Programming
 
In what way can C++0x standard help you eliminate 64-bit errors
In what way can C++0x standard help you eliminate 64-bit  errorsIn what way can C++0x standard help you eliminate 64-bit  errors
In what way can C++0x standard help you eliminate 64-bit errors
 
Aes128 bit project_report
Aes128 bit project_reportAes128 bit project_report
Aes128 bit project_report
 
Конверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемыеКонверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемые
 
Parallel Adder and Subtractor
Parallel Adder and SubtractorParallel Adder and Subtractor
Parallel Adder and Subtractor
 
Binary parallel adder
Binary parallel adderBinary parallel adder
Binary parallel adder
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
 
Adder & subtractor (Half adder, Full adder, Half subtractor, Full subtractor)
Adder & subtractor (Half adder, Full adder, Half subtractor, Full subtractor)Adder & subtractor (Half adder, Full adder, Half subtractor, Full subtractor)
Adder & subtractor (Half adder, Full adder, Half subtractor, Full subtractor)
 
Chapter 03 arithmetic for computers
Chapter 03   arithmetic for computersChapter 03   arithmetic for computers
Chapter 03 arithmetic for computers
 
Arithmetic Operations
Arithmetic OperationsArithmetic Operations
Arithmetic Operations
 
A (brief) overview of Span<T>
A (brief) overview of Span<T>A (brief) overview of Span<T>
A (brief) overview of Span<T>
 
Aes
AesAes
Aes
 
SunPy: Python for solar physics
SunPy: Python for solar physicsSunPy: Python for solar physics
SunPy: Python for solar physics
 
Signed Addition And Subtraction
Signed Addition And SubtractionSigned Addition And Subtraction
Signed Addition And Subtraction
 
Computer Arithmetic
Computer ArithmeticComputer Arithmetic
Computer Arithmetic
 
Csc1401 lecture03 - computer arithmetic - arithmetic and logic unit (alu)
Csc1401   lecture03 - computer arithmetic - arithmetic and logic unit (alu)Csc1401   lecture03 - computer arithmetic - arithmetic and logic unit (alu)
Csc1401 lecture03 - computer arithmetic - arithmetic and logic unit (alu)
 

Viewers also liked

User defined data type
User defined data typeUser defined data type
User defined data typeAmit Kapoor
 
Types of memory 10 to11
Types of memory 10 to11Types of memory 10 to11
Types of memory 10 to11myrajendra
 
Types of memory
Types of memoryTypes of memory
Types of memorymyrajendra
 
Chapter 2 basic element of programming
Chapter 2 basic element of programming Chapter 2 basic element of programming
Chapter 2 basic element of programming Zul Aiman
 
C++ Programming
C++ ProgrammingC++ Programming
C++ Programming
Rounak Samdadia
 
Hibernate example1
Hibernate example1Hibernate example1
Hibernate example1
myrajendra
 
38 paged segmentation
38 paged segmentation38 paged segmentation
38 paged segmentationmyrajendra
 
Fundamentals
FundamentalsFundamentals
Fundamentals
myrajendra
 
File management53(1)
File management53(1)File management53(1)
File management53(1)myrajendra
 
35. multiplepartitionallocation
35. multiplepartitionallocation35. multiplepartitionallocation
35. multiplepartitionallocationmyrajendra
 
36 fragmentaio nnd pageconcepts
36 fragmentaio nnd pageconcepts36 fragmentaio nnd pageconcepts
36 fragmentaio nnd pageconceptsmyrajendra
 
40 demand paging
40 demand paging40 demand paging
40 demand pagingmyrajendra
 
Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43myrajendra
 
C++ Language
C++ LanguageC++ Language
C++ Language
Syed Zaid Irshad
 
39 virtual memory
39 virtual memory39 virtual memory
39 virtual memorymyrajendra
 
Data types
Data typesData types
Data types
Syed Umair
 
37 segmentation
37 segmentation37 segmentation
37 segmentationmyrajendra
 
Segmentation in Operating Systems.
Segmentation in Operating Systems.Segmentation in Operating Systems.
Segmentation in Operating Systems.
Muhammad SiRaj Munir
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
Inshad Arshad
 

Viewers also liked (20)

User defined data type
User defined data typeUser defined data type
User defined data type
 
Elements of programming
Elements of programmingElements of programming
Elements of programming
 
Types of memory 10 to11
Types of memory 10 to11Types of memory 10 to11
Types of memory 10 to11
 
Types of memory
Types of memoryTypes of memory
Types of memory
 
Chapter 2 basic element of programming
Chapter 2 basic element of programming Chapter 2 basic element of programming
Chapter 2 basic element of programming
 
C++ Programming
C++ ProgrammingC++ Programming
C++ Programming
 
Hibernate example1
Hibernate example1Hibernate example1
Hibernate example1
 
38 paged segmentation
38 paged segmentation38 paged segmentation
38 paged segmentation
 
Fundamentals
FundamentalsFundamentals
Fundamentals
 
File management53(1)
File management53(1)File management53(1)
File management53(1)
 
35. multiplepartitionallocation
35. multiplepartitionallocation35. multiplepartitionallocation
35. multiplepartitionallocation
 
36 fragmentaio nnd pageconcepts
36 fragmentaio nnd pageconcepts36 fragmentaio nnd pageconcepts
36 fragmentaio nnd pageconcepts
 
40 demand paging
40 demand paging40 demand paging
40 demand paging
 
Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
39 virtual memory
39 virtual memory39 virtual memory
39 virtual memory
 
Data types
Data typesData types
Data types
 
37 segmentation
37 segmentation37 segmentation
37 segmentation
 
Segmentation in Operating Systems.
Segmentation in Operating Systems.Segmentation in Operating Systems.
Segmentation in Operating Systems.
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
 

Similar to Data type

embedded C.pptx
embedded C.pptxembedded C.pptx
embedded C.pptx
mohammedahmed539376
 
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
Julien Le Dem
 
Efficient Data Storage for Analytics with Apache Parquet 2.0
Efficient Data Storage for Analytics with Apache Parquet 2.0Efficient Data Storage for Analytics with Apache Parquet 2.0
Efficient Data Storage for Analytics with Apache Parquet 2.0Cloudera, Inc.
 
Acm aleppo cpc training second session
Acm aleppo cpc training second sessionAcm aleppo cpc training second session
Acm aleppo cpc training second session
Ahmad Bashar Eter
 
Development of a static code analyzer for detecting errors of porting program...
Development of a static code analyzer for detecting errors of porting program...Development of a static code analyzer for detecting errors of porting program...
Development of a static code analyzer for detecting errors of porting program...
PVS-Studio
 
Low Level Prog. (from 201-c).ppt
Low Level Prog. (from 201-c).pptLow Level Prog. (from 201-c).ppt
Low Level Prog. (from 201-c).ppt
LearnWithJCM
 
Getting started cpp full
Getting started cpp   fullGetting started cpp   full
Getting started cpp full
Võ Hòa
 
A 64-bit horse that can count
A 64-bit horse that can countA 64-bit horse that can count
A 64-bit horse that can count
Andrey Karpov
 
The article is a report about testing of portability of Loki library with 64-...
The article is a report about testing of portability of Loki library with 64-...The article is a report about testing of portability of Loki library with 64-...
The article is a report about testing of portability of Loki library with 64-...
PVS-Studio
 
DConf 2016: Bitpacking Like a Madman by Amaury Sechet
DConf 2016: Bitpacking Like a Madman by Amaury SechetDConf 2016: Bitpacking Like a Madman by Amaury Sechet
DConf 2016: Bitpacking Like a Madman by Amaury Sechet
Andrei Alexandrescu
 
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...Positive Hack Days
 
A nice 64-bit error in C
A  nice 64-bit error in CA  nice 64-bit error in C
A nice 64-bit error in C
PVS-Studio
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
Qazi Shahzad Ali
 
Happy To Use SIMD
Happy To Use SIMDHappy To Use SIMD
Happy To Use SIMD
Wei-Ta Wang
 
C++11 and 64-bit Issues
C++11 and 64-bit IssuesC++11 and 64-bit Issues
C++11 and 64-bit Issues
Andrey Karpov
 
Learning python
Learning pythonLearning python
Learning python
Tony Nguyen
 
Learning python
Learning pythonLearning python
Learning python
Fraboni Ec
 
Learning python
Learning pythonLearning python
Learning python
Hoang Nguyen
 
Learning python
Learning pythonLearning python
Learning python
Harry Potter
 
Learning python
Learning pythonLearning python
Learning python
James Wong
 

Similar to Data type (20)

embedded C.pptx
embedded C.pptxembedded C.pptx
embedded C.pptx
 
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
 
Efficient Data Storage for Analytics with Apache Parquet 2.0
Efficient Data Storage for Analytics with Apache Parquet 2.0Efficient Data Storage for Analytics with Apache Parquet 2.0
Efficient Data Storage for Analytics with Apache Parquet 2.0
 
Acm aleppo cpc training second session
Acm aleppo cpc training second sessionAcm aleppo cpc training second session
Acm aleppo cpc training second session
 
Development of a static code analyzer for detecting errors of porting program...
Development of a static code analyzer for detecting errors of porting program...Development of a static code analyzer for detecting errors of porting program...
Development of a static code analyzer for detecting errors of porting program...
 
Low Level Prog. (from 201-c).ppt
Low Level Prog. (from 201-c).pptLow Level Prog. (from 201-c).ppt
Low Level Prog. (from 201-c).ppt
 
Getting started cpp full
Getting started cpp   fullGetting started cpp   full
Getting started cpp full
 
A 64-bit horse that can count
A 64-bit horse that can countA 64-bit horse that can count
A 64-bit horse that can count
 
The article is a report about testing of portability of Loki library with 64-...
The article is a report about testing of portability of Loki library with 64-...The article is a report about testing of portability of Loki library with 64-...
The article is a report about testing of portability of Loki library with 64-...
 
DConf 2016: Bitpacking Like a Madman by Amaury Sechet
DConf 2016: Bitpacking Like a Madman by Amaury SechetDConf 2016: Bitpacking Like a Madman by Amaury Sechet
DConf 2016: Bitpacking Like a Madman by Amaury Sechet
 
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
 
A nice 64-bit error in C
A  nice 64-bit error in CA  nice 64-bit error in C
A nice 64-bit error in C
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
 
Happy To Use SIMD
Happy To Use SIMDHappy To Use SIMD
Happy To Use SIMD
 
C++11 and 64-bit Issues
C++11 and 64-bit IssuesC++11 and 64-bit Issues
C++11 and 64-bit Issues
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 

More from myrajendra

Jdbc workflow
Jdbc workflowJdbc workflow
Jdbc workflow
myrajendra
 
2 jdbc drivers
2 jdbc drivers2 jdbc drivers
2 jdbc drivers
myrajendra
 
3 jdbc api
3 jdbc api3 jdbc api
3 jdbc api
myrajendra
 
4 jdbc step1
4 jdbc step14 jdbc step1
4 jdbc step1
myrajendra
 
Dao example
Dao exampleDao example
Dao example
myrajendra
 
Sessionex1
Sessionex1Sessionex1
Sessionex1
myrajendra
 
1 introduction to html
1 introduction to html1 introduction to html
1 introduction to htmlmyrajendra
 
Views
ViewsViews
Views
myrajendra
 
Java.sql package
Java.sql packageJava.sql package
Java.sql packagemyrajendra
 
Interface callable statement
Interface callable statementInterface callable statement
Interface callable statementmyrajendra
 

More from myrajendra (20)

Jdbc workflow
Jdbc workflowJdbc workflow
Jdbc workflow
 
2 jdbc drivers
2 jdbc drivers2 jdbc drivers
2 jdbc drivers
 
3 jdbc api
3 jdbc api3 jdbc api
3 jdbc api
 
4 jdbc step1
4 jdbc step14 jdbc step1
4 jdbc step1
 
Dao example
Dao exampleDao example
Dao example
 
Sessionex1
Sessionex1Sessionex1
Sessionex1
 
Internal
InternalInternal
Internal
 
3. elements
3. elements3. elements
3. elements
 
2. attributes
2. attributes2. attributes
2. attributes
 
1 introduction to html
1 introduction to html1 introduction to html
1 introduction to html
 
Headings
HeadingsHeadings
Headings
 
Forms
FormsForms
Forms
 
Css
CssCss
Css
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Starting jdbc
Starting jdbcStarting jdbc
Starting jdbc
 
Properties
PropertiesProperties
Properties
 
Java.sql package
Java.sql packageJava.sql package
Java.sql package
 
Interface callable statement
Interface callable statementInterface callable statement
Interface callable statement
 

Recently uploaded

Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
Delivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and TrainingDelivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and Training
AG2 Design
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Landownership in the Philippines under the Americans-2-pptx.pptx
Landownership in the Philippines under the Americans-2-pptx.pptxLandownership in the Philippines under the Americans-2-pptx.pptx
Landownership in the Philippines under the Americans-2-pptx.pptx
JezreelCabil2
 
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
 
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 simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
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
 
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
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
ArianaBusciglio
 

Recently uploaded (20)

Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
Delivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and TrainingDelivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and Training
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Landownership in the Philippines under the Americans-2-pptx.pptx
Landownership in the Philippines under the Americans-2-pptx.pptxLandownership in the Philippines under the Americans-2-pptx.pptx
Landownership in the Philippines under the Americans-2-pptx.pptx
 
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
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
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...
 
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
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
 

Data type

  • 2. 2 Declaration • All variables must be declared before being used. – Tells compiler to set aside an appropriate amount of space in memory to hold a value. – Enables the compiler to perform operations using the declared variables. http://improvec.blogspot.in
  • 3. 3 Basic Data Types • char character • int integer • float floating-point • double double floating-point • void valueless http://improvec.blogspot.in
  • 4. 4 Modifying the Basic Types • Type modifier: signed unsigned long short • When a type modifier is used by itself, then int is assumed. Modifier Same As signed signed int unsigned unsigned int long long int short short int http://improvec.blogspot.in
  • 5. 5 Data Type char Have Seen:Chars are treated as small integers & conversely small ints are treated as chars. char c = ‘a’; printf (“%c”, c + 1) b printf (“%d”, c + 2) 99 Each char variable stored in 1 Byte 8 Bits: 27 26 25 24 23 22 21 20 128 64 32 16 8 4 2 1 a 0000110 1http://improvec.blogspot.in
  • 6. 6 • String of binary digits are called bit strings. • A bit string is interpreted as a binary number. bnbn-1 …… b2b1b0 0 1 1 0 0 0 0 1 a • This bit string has the value: 1×26 + 1×25 + 1×20 = 97http://improvec.blogspot.in
  • 7. 7 3 types: 1) char 2) unsigned char 3) signed char Each uses 1 Byte. Signed char -128 to 127 Unsigned char 0 to 255 http://improvec.blogspot.in
  • 8. 8 INTEGERS : Include the natural counting numbers and their negatives. INTEGRAL DATA TYPES: int short long unsigned Data Type int http://improvec.blogspot.in
  • 9. 9 • The magnitude of the number that an int variable can hold depends on ___________? 2 Byte word ~ -32 K To +32K -215 , …, -3, -2, -1, 0, 1, 2, 3, …, 215 -1 4 Byte word ~ -2 Billion To +2 Billion -231 , …. -3, -2, -1, 0, 1, 2, 3, …, 231 -1 word size(bits) of the machine is machine dependent http://improvec.blogspot.in
  • 10. 10 • Integer overflow: – Value too large for defined Storage Location. – Typically program continues to run but incorrect results. – The programmer must strive at all times to avoid integer overflow. http://improvec.blogspot.in
  • 11. 11 Types short, long, unsigned • short - used where conserving storage is a concern (usually 2 Bytes). -32 Thousand To +32 Thousand -215 , -215 +1, …, -3, -2, -1, 0, 1, 2, 3, …, 215 -1 • long - needed for larger integers (usually 4 bytes). -2 Billion To +2 Billion 31 31 31 http://improvec.blogspot.in
  • 12. 12 • Unsigned - no sign bit, same number bytes as int. The range, u, of values: 0 ≤ u ≤ 2wordsize -1 2 Byte word ~ 0 To + 64 Thousand 0, 1, 2, 3, …, 216 -1 4 Byte word ~ 0 To + 4 Billion 0, 1, 2, 3, …, 232 -1http://improvec.blogspot.in
  • 13. 13 Suffix: u - 20u l – 20l ul - 20ul (case not significant) IF no suffix with constant - system will choose the first of : int - long - unsigned long That can hold the value. http://improvec.blogspot.in
  • 14. 14 float double long double • Suffixes for constants f or F float 3.7 F l or L long double 3.7 L • Any unsuffixed floating constant is of type double (working type). The Floating Types http://improvec.blogspot.in
  • 15. 15 • Notation: exponential or decimal Must have Exponent or Dec pt or Both. 1.234567e5 123456.7 1.234567e-3 0.001234567 0e0 correct 0.0 .e0 wrong May not contain any blanks or special characters. • Typical Storage: Float < Double http://improvec.blogspot.in
  • 16. 16 Precision: The number of significant decimal digits that floating value carries. Range: Limits of largest & smallest possible values that can be in a variable of that type. Float: 4 Bytes - about 6 decimal places of accuracy- single precision. Double: 8 Bytes - about 15 decimal places of accuracy- double precision.http://improvec.blogspot.in
  • 17. 17 Internal Representation FLOAT: 01 8 9 31 SEEEEEEEE mmmmm…m DOUBLE: 01 11 12 63 SEEEEEEEEEEE mmmmmmm…m Implied mantissa of 1 is not stored. Sign bit (1 for neg-otherwise pos).http://improvec.blogspot.in
  • 18. 18 Float: Precision: 6 significant digits. Range: 10-38 to 10+38 0.d1d2d3d4d5d6× 10n Double: Precision: 15 significant digits (252 ≈ 1015 ) Range: 10-308 to 10+308 0.123451234512345 × 103 http://improvec.blogspot.in
  • 19. 19 Note: 1. Not all Real numbers are exactly representable in binary memory. 2. Floating Arithmetic ops, unlike integer arithmetic, may not be exact. http://improvec.blogspot.in
  • 20. 20 • Unary operator used to find the number of Bytes needed to store an object. sizeof(object) • Object – Data type int , float, … – Expression a + b Array Will cover later Structure Compile-Time Operator sizeof http://improvec.blogspot.in
  • 21. 21 Assuming that integers are 4 bytes and doubles are 8 bytes. double f; printf("%d ",sizeof (f)); 8 printf(''%d", sizeof(int)); 4 http://improvec.blogspot.in
  • 22. 22 sizeof(char) = 1 sizeof(short) ≤ sizeof(int) ≤ sizeof(long) sizeof(signed)=sizeof(unsigned)=sizeof(int) sizeof(float) <= sizeof(double ) <= sizeof( long double) http://improvec.blogspot.in
  • 23. 23 Conversions • When constants and variables of different types are mixed in an expression, the compiler converts all operands to the type of the largest operand- Called Type Promotion. - First, all char and short values are automatically elevated to int. Called integral promotion. - int + int = int - short + short = int - Arithmetic Conversion (See pg. 217) http://improvec.blogspot.in
  • 24. 24 char ch; int i; float f; double d,result; result= (ch / i) + (f * d) – (f + i); int double float double http://improvec.blogspot.in
  • 25. 25 • Casts - Explicit conversions. (type) expression If i is int: (float) i will change expression value to float, i is not changed. Casts (float) i/2 http://improvec.blogspot.in
  • 26. 26 • Apply to an Expression: (float) (‘c’ + 3) • Cannot apply to an Assignment: (int) f = 3: illegal • As an unary operator, a cast has the same precedence as any other unary operator. (float) i + 3 ( (float) i ) + 3 http://improvec.blogspot.in
  • 27. 27 /* print i and i/2 with fractions */ int main(void) { int i; for(i=l; i<=100; ++i) printf(''%d //2 is: %f n", i, (float) i /2); return 0; } http://improvec.blogspot.in
  • 28. 28 General forms: (int) char expression- ordinal value of char expression (char) int expression- character with the ordinal value of int expression (int) float expression- truncates the float expression (float) int expression- converts int to float (double) float exp- converts float to doublehttp://improvec.blogspot.in