SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Prepared By:
Savani Nirali
Sanghani Monika
Patel Pooja
How and Where C datatypes are
stored in Memory
C Data types:
 Basic Types:
They are arithmetic types and consists of the two
types: (a) integer types and (b) floating-point types.
 Enumerated types:
They are again arithmetic types and they are
used to define variables that can only be assigned
certain discrete integer values throughout the
program.
 The type void:
The type specifier void indicates that no value is
available.
 Derived types:
They include (a) Pointer types, (b) Array types,
(c) Structure types, (d) Union types and (e) Function
Integer Types:
Type Storage size Value range
Char 1 byte -128 to 127 or 0 to 255
Unsigned Char 1 byte 0 to 255
Signed Char 1 byte -128 to 127
int 2 or 4 bytes -32,768 to 32,767 or
-2,147,483,648 to 2,147,483,647
Unsigned int 2 or 4 bytes 0 to 65,535 or
0 to 4,294,967,295
short 2 bytes -32,768 to 32,767
Unsigned short 2 bytes 0 to 65,535
long 4 bytes -2,147,483,648 to 2,147,483,647
Unsigned long 4 bytes 0 to 4,294,967,295
 Memory representation of char data type in C
Char data types may be signed or unsigned. Size of char data
type is 8 bit. Both signed and unsigned have different memory
representation.
Memory representation of unsigned char: In unsigned char all 8 bit
is used as data bit
Memory representation of unsigned char a= 7;
Binary equivalent of 7 is: 111
For 8 bit we will add 5 zero in the left side i.e. 00000111. In the
memory:
 Here MSD stand for most significant digit and LSD list significant
digit.
 Memory representation of signed char:
1 bit: signed bit
7 bit: data bit
Note: In C, negative number is stored in the 2’s complement format.
Signed bit is 0: Number is positive.
Signed bit is 1: Number is negative.
Memory representation of char a=7;
Binary equivalent of 7 is: 111
For 8 bit we will add 5 zero in the left side i.e. 00000111. Memory
representation:
 Memory representation of char a=-7;
Binary equivalent of 7 is 111
For 8 bit we will add 5 zero in the left side i.e. 00000111. Since a
is negative number so it will store in the memory in the 2’s
complement format
 1’s complement of a: 11111000
+ 1
____________
 2’s complement of a: 11111001
Memory representation:
Floating Point Types:
Type Storage value Value range Precision
Float 4 byte 1.2E-38 to 3.4E+38 6 decimal places
double 8 byte
2.3E-308 to 1.7E+308
15 decimal places
Long double 10-byte 3.4E-4932 to 1.1E+4932 19 decimal places
 To get the exact size of a type or a variable on a particular platform, you can use the
sizeof operator. The expressions sizeof(type) yields the storage size of the object or type
in bytes. Following is an example:
#include <stdio.h>
#include <conio.h>
#include <float.h>
int main(){
printf("Storage size for int : %d n", sizeof(int));
printf("Storage size for float : %d n", sizeof(float));
printf("Minimum float positive value: %En", FLT_MIN );
printf("Maximum float positive value: %En", FLT_MAX );
return 0;
}
When you compile and execute the above program it produces the following
result on Linux:
Storage size for int : 4
Storage size for float : 4
Minimum float positive value: 1.175494E-38
Maximum float positive value: 3.402823E+38
The Void Type:
Serial
Number
:
Types and Description
1 Function returns as void :
There are various functions in C which do not return value or
you can say they return void. A function with no return value has
the return type as void. For example void exit (int status);
2 Function arguments as void
There are various functions in C which do not accept any
parameter. A function with no parameter can accept as a void.
For example, int rand(void);
3 Pointers to void
A pointer of type void * represents the address of an object, but
not its type. For example a memory allocation function void
*malloc( size_t size ); returns a pointer to void which can be
casted to any data type.
Enum [Enumerated] data types:
 Syntax:
enum identifier {value1, value2,.... Value n};
 enum is ” Enumerated Data Type “.
 enum is user defined data type
 In the above example “identifier” is nothing but the user defined data
type .
 Value1,Value2,Value3….. etc creates one set of enum values.
 Using “identifier” we are creating our variables.
Memory Layout
 Text or Code Segment
Code segment, also known as text segment contains
machine code of the compiled program. The text segment of an
executable object file is often read-only segment that prevents a
program from being accidentally modified.
 Data Segments
Data segment stores program data. This data could be in
form of initialized or uninitialized variables, and it could be local
or global.
Data segment is further divided into four sub-data
segments (initialized data segment, uninitialized or .bss data
segment, stack, and heap) to store variables depending upon if
they are local or global, and initialized or uninitialized.
Memory Layout (Cont.)
 Initialized Data or Data Segment
Initialized data or simply data segment stores all global,
static, constant, and external variables (declared
with extern keyword) that are initialized beforehand.
 Uninitialized Data or .bss Segment
Contrary to initialized data segment, uninitialized
data or .bss segment stores all uninitialized global, static, and
external variables (declared with extern keyword). Global,
external, and static variable are by default initialized to zero.
Object file formats distinguish between initialized and
uninitialized variables for space efficiency; uninitialized
variables do not have to occupy any actual disk space in the
object file.
Memory Layout (Cont.)
Figure 1 : Memory Layout of C Program
Memory Layout (Cont.)
 Stack Segment
Stack segment is used to store all local variables and is
used for passing arguments to the functions along with the return
address of the instruction which is to be executed after the
function call is over. Local pointers are stored in stack segment.
 Heap Segment
Heap segment is also part of RAM where dynamically
allocated variables are stored. In C language dynamic memory
allocation is done by using malloc and calloc functions. Global
pointers are automatically stored in Heap segment.
When some more memory need to be allocated
using malloc and calloc function, heap grows upward as shown
in Figure 1.
Big and Little Endian
 Big Endian : In big endian, you store the most significant byte
in the smallest address.
 Little Endian : In little endian, you store the least significant
byte in the smallest address.
THANK YOU

Weitere ähnliche Inhalte

Was ist angesagt?

linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structuresDurgaDeviCbit
 
Data Structure and Algorithms The Tower of Hanoi
Data Structure and Algorithms The Tower of HanoiData Structure and Algorithms The Tower of Hanoi
Data Structure and Algorithms The Tower of HanoiManishPrajapati78
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1Shashwat Shriparv
 
Stack and its usage in assembly language
Stack and its usage in assembly language Stack and its usage in assembly language
Stack and its usage in assembly language Usman Bin Saad
 
BASICS OF DATA STRUCTURE
BASICS OF DATA STRUCTUREBASICS OF DATA STRUCTURE
BASICS OF DATA STRUCTUREVENNILAV6
 
Attributes of Output Primitives
Attributes of Output PrimitivesAttributes of Output Primitives
Attributes of Output PrimitivesRenita Santhmayora
 
Lec 03 ia32 architecture
Lec 03  ia32 architectureLec 03  ia32 architecture
Lec 03 ia32 architectureAbdul Khan
 
Minmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesMinmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesSamiaAziz4
 
What is identifier c programming
What is identifier c programmingWhat is identifier c programming
What is identifier c programmingRumman Ansari
 
File Handling Python
File Handling PythonFile Handling Python
File Handling PythonAkhil Kaushik
 
Data Type Conversion in C++
Data Type Conversion in C++Data Type Conversion in C++
Data Type Conversion in C++Danial Mirza
 
Chapter 9 morphological image processing
Chapter 9 morphological image processingChapter 9 morphological image processing
Chapter 9 morphological image processingasodariyabhavesh
 

Was ist angesagt? (20)

linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structures
 
Data Structure and Algorithms The Tower of Hanoi
Data Structure and Algorithms The Tower of HanoiData Structure and Algorithms The Tower of Hanoi
Data Structure and Algorithms The Tower of Hanoi
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1
 
Stack and its usage in assembly language
Stack and its usage in assembly language Stack and its usage in assembly language
Stack and its usage in assembly language
 
BASICS OF DATA STRUCTURE
BASICS OF DATA STRUCTUREBASICS OF DATA STRUCTURE
BASICS OF DATA STRUCTURE
 
Attributes of Output Primitives
Attributes of Output PrimitivesAttributes of Output Primitives
Attributes of Output Primitives
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
Python list
Python listPython list
Python list
 
Lec 03 ia32 architecture
Lec 03  ia32 architectureLec 03  ia32 architecture
Lec 03 ia32 architecture
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Files in c++
Files in c++Files in c++
Files in c++
 
1 sollins algorithm
1 sollins algorithm1 sollins algorithm
1 sollins algorithm
 
Minmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesMinmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slides
 
What is identifier c programming
What is identifier c programmingWhat is identifier c programming
What is identifier c programming
 
File Handling Python
File Handling PythonFile Handling Python
File Handling Python
 
Linker and Loader
Linker and Loader Linker and Loader
Linker and Loader
 
2D Array
2D Array 2D Array
2D Array
 
Loaders
LoadersLoaders
Loaders
 
Data Type Conversion in C++
Data Type Conversion in C++Data Type Conversion in C++
Data Type Conversion in C++
 
Chapter 9 morphological image processing
Chapter 9 morphological image processingChapter 9 morphological image processing
Chapter 9 morphological image processing
 

Andere mochten auch

C language UPTU Unit3 Slides
C language UPTU Unit3 SlidesC language UPTU Unit3 Slides
C language UPTU Unit3 SlidesRakesh Roshan
 
C language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C languageC language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C languageRakesh Roshan
 
Mechanics of materials
Mechanics of materialsMechanics of materials
Mechanics of materialsSelf-employed
 
differential equations Boyce & Diprima Solution manual
differential equations Boyce & Diprima Solution manualdifferential equations Boyce & Diprima Solution manual
differential equations Boyce & Diprima Solution manualshayangreen
 
2 axial loading- Mechanics of Materials - 4th - Beer
2 axial loading- Mechanics of Materials - 4th - Beer2 axial loading- Mechanics of Materials - 4th - Beer
2 axial loading- Mechanics of Materials - 4th - BeerNhan Tran
 
3 torsion- Mechanics of Materials - 4th - Beer
3 torsion- Mechanics of Materials - 4th - Beer3 torsion- Mechanics of Materials - 4th - Beer
3 torsion- Mechanics of Materials - 4th - BeerNhan Tran
 
Higher Differential Equation
Higher Differential EquationHigher Differential Equation
Higher Differential Equationgtuautonomous
 
02 first order differential equations
02 first order differential equations02 first order differential equations
02 first order differential equationsvansi007
 
Mechanics of materials lecture 01, Engr. Abdullah Khan
Mechanics of materials lecture 01, Engr. Abdullah KhanMechanics of materials lecture 01, Engr. Abdullah Khan
Mechanics of materials lecture 01, Engr. Abdullah KhanAbdullah Khan
 
Higher Differential Equation
Higher Differential Equation Higher Differential Equation
Higher Differential Equation Abdul Hannan
 

Andere mochten auch (13)

Unit4 Slides
Unit4 SlidesUnit4 Slides
Unit4 Slides
 
C language UPTU Unit3 Slides
C language UPTU Unit3 SlidesC language UPTU Unit3 Slides
C language UPTU Unit3 Slides
 
C language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C languageC language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C language
 
Mechanics of materials
Mechanics of materialsMechanics of materials
Mechanics of materials
 
differential equations Boyce & Diprima Solution manual
differential equations Boyce & Diprima Solution manualdifferential equations Boyce & Diprima Solution manual
differential equations Boyce & Diprima Solution manual
 
Higher order differential equations
Higher order differential equationsHigher order differential equations
Higher order differential equations
 
Unit 2 stresses in composite sections
Unit 2  stresses in composite sectionsUnit 2  stresses in composite sections
Unit 2 stresses in composite sections
 
2 axial loading- Mechanics of Materials - 4th - Beer
2 axial loading- Mechanics of Materials - 4th - Beer2 axial loading- Mechanics of Materials - 4th - Beer
2 axial loading- Mechanics of Materials - 4th - Beer
 
3 torsion- Mechanics of Materials - 4th - Beer
3 torsion- Mechanics of Materials - 4th - Beer3 torsion- Mechanics of Materials - 4th - Beer
3 torsion- Mechanics of Materials - 4th - Beer
 
Higher Differential Equation
Higher Differential EquationHigher Differential Equation
Higher Differential Equation
 
02 first order differential equations
02 first order differential equations02 first order differential equations
02 first order differential equations
 
Mechanics of materials lecture 01, Engr. Abdullah Khan
Mechanics of materials lecture 01, Engr. Abdullah KhanMechanics of materials lecture 01, Engr. Abdullah Khan
Mechanics of materials lecture 01, Engr. Abdullah Khan
 
Higher Differential Equation
Higher Differential Equation Higher Differential Equation
Higher Differential Equation
 

Ähnlich wie Memory management of datatypes

datatypes-200723165518 (1).pptx
datatypes-200723165518 (1).pptxdatatypes-200723165518 (1).pptx
datatypes-200723165518 (1).pptxNaniBhai3
 
Programming Fundamentals lecture 6
Programming Fundamentals lecture 6Programming Fundamentals lecture 6
Programming Fundamentals lecture 6REHAN IJAZ
 
Fundamentals of Programming Constructs.pptx
Fundamentals of  Programming Constructs.pptxFundamentals of  Programming Constructs.pptx
Fundamentals of Programming Constructs.pptxvijayapraba1
 
Unit 1 Built in Data types in C language.ppt
Unit 1 Built in Data types in C language.pptUnit 1 Built in Data types in C language.ppt
Unit 1 Built in Data types in C language.pptpubgnewstate1620
 
C Sharp Nagina (1)
C Sharp Nagina (1)C Sharp Nagina (1)
C Sharp Nagina (1)guest58c84c
 
C Sharp Jn (1)
C Sharp Jn (1)C Sharp Jn (1)
C Sharp Jn (1)jahanullah
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorialMohit Saini
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introductionnikshaikh786
 
Programming construction tools
Programming construction toolsProgramming construction tools
Programming construction toolssunilchute1
 
Data Reprersentation
Data Reprersentation  Data Reprersentation
Data Reprersentation Kamal Acharya
 
5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt5-Lec - Datatypes.ppt
5-Lec - Datatypes.pptAqeelAbbas94
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C ProgrammingQazi Shahzad Ali
 
Literals, primitive datatypes, variables, expressions, identifiers
Literals, primitive datatypes, variables, expressions, identifiersLiterals, primitive datatypes, variables, expressions, identifiers
Literals, primitive datatypes, variables, expressions, identifiersTanishq Soni
 
Variables in C++, data types in c++
Variables in C++, data types in c++Variables in C++, data types in c++
Variables in C++, data types in c++Neeru Mittal
 

Ähnlich wie Memory management of datatypes (20)

datatypes-200723165518 (1).pptx
datatypes-200723165518 (1).pptxdatatypes-200723165518 (1).pptx
datatypes-200723165518 (1).pptx
 
PSPC--UNIT-2.pdf
PSPC--UNIT-2.pdfPSPC--UNIT-2.pdf
PSPC--UNIT-2.pdf
 
Programming Fundamentals lecture 6
Programming Fundamentals lecture 6Programming Fundamentals lecture 6
Programming Fundamentals lecture 6
 
Fundamentals of Programming Constructs.pptx
Fundamentals of  Programming Constructs.pptxFundamentals of  Programming Constructs.pptx
Fundamentals of Programming Constructs.pptx
 
Theory1&amp;2
Theory1&amp;2Theory1&amp;2
Theory1&amp;2
 
Unit 1 Built in Data types in C language.ppt
Unit 1 Built in Data types in C language.pptUnit 1 Built in Data types in C language.ppt
Unit 1 Built in Data types in C language.ppt
 
C Sharp Nagina (1)
C Sharp Nagina (1)C Sharp Nagina (1)
C Sharp Nagina (1)
 
C Sharp Jn (1)
C Sharp Jn (1)C Sharp Jn (1)
C Sharp Jn (1)
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorial
 
Chapter 2.datatypes and operators
Chapter 2.datatypes and operatorsChapter 2.datatypes and operators
Chapter 2.datatypes and operators
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introduction
 
Structured Languages
Structured LanguagesStructured Languages
Structured Languages
 
Programming construction tools
Programming construction toolsProgramming construction tools
Programming construction tools
 
Data Reprersentation
Data Reprersentation  Data Reprersentation
Data Reprersentation
 
5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
 
Literals, primitive datatypes, variables, expressions, identifiers
Literals, primitive datatypes, variables, expressions, identifiersLiterals, primitive datatypes, variables, expressions, identifiers
Literals, primitive datatypes, variables, expressions, identifiers
 
5 introduction-to-c
5 introduction-to-c5 introduction-to-c
5 introduction-to-c
 
datareprersentation 1.pptx
datareprersentation 1.pptxdatareprersentation 1.pptx
datareprersentation 1.pptx
 
Variables in C++, data types in c++
Variables in C++, data types in c++Variables in C++, data types in c++
Variables in C++, data types in c++
 

Kürzlich hochgeladen

Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 

Kürzlich hochgeladen (20)

Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 

Memory management of datatypes

  • 1. Prepared By: Savani Nirali Sanghani Monika Patel Pooja How and Where C datatypes are stored in Memory
  • 2. C Data types:  Basic Types: They are arithmetic types and consists of the two types: (a) integer types and (b) floating-point types.  Enumerated types: They are again arithmetic types and they are used to define variables that can only be assigned certain discrete integer values throughout the program.  The type void: The type specifier void indicates that no value is available.  Derived types: They include (a) Pointer types, (b) Array types, (c) Structure types, (d) Union types and (e) Function
  • 3. Integer Types: Type Storage size Value range Char 1 byte -128 to 127 or 0 to 255 Unsigned Char 1 byte 0 to 255 Signed Char 1 byte -128 to 127 int 2 or 4 bytes -32,768 to 32,767 or -2,147,483,648 to 2,147,483,647 Unsigned int 2 or 4 bytes 0 to 65,535 or 0 to 4,294,967,295 short 2 bytes -32,768 to 32,767 Unsigned short 2 bytes 0 to 65,535 long 4 bytes -2,147,483,648 to 2,147,483,647 Unsigned long 4 bytes 0 to 4,294,967,295
  • 4.  Memory representation of char data type in C Char data types may be signed or unsigned. Size of char data type is 8 bit. Both signed and unsigned have different memory representation. Memory representation of unsigned char: In unsigned char all 8 bit is used as data bit Memory representation of unsigned char a= 7; Binary equivalent of 7 is: 111 For 8 bit we will add 5 zero in the left side i.e. 00000111. In the memory:  Here MSD stand for most significant digit and LSD list significant digit.
  • 5.  Memory representation of signed char: 1 bit: signed bit 7 bit: data bit Note: In C, negative number is stored in the 2’s complement format. Signed bit is 0: Number is positive. Signed bit is 1: Number is negative. Memory representation of char a=7; Binary equivalent of 7 is: 111 For 8 bit we will add 5 zero in the left side i.e. 00000111. Memory representation:
  • 6.  Memory representation of char a=-7; Binary equivalent of 7 is 111 For 8 bit we will add 5 zero in the left side i.e. 00000111. Since a is negative number so it will store in the memory in the 2’s complement format  1’s complement of a: 11111000 + 1 ____________  2’s complement of a: 11111001 Memory representation:
  • 7. Floating Point Types: Type Storage value Value range Precision Float 4 byte 1.2E-38 to 3.4E+38 6 decimal places double 8 byte 2.3E-308 to 1.7E+308 15 decimal places Long double 10-byte 3.4E-4932 to 1.1E+4932 19 decimal places
  • 8.  To get the exact size of a type or a variable on a particular platform, you can use the sizeof operator. The expressions sizeof(type) yields the storage size of the object or type in bytes. Following is an example: #include <stdio.h> #include <conio.h> #include <float.h> int main(){ printf("Storage size for int : %d n", sizeof(int)); printf("Storage size for float : %d n", sizeof(float)); printf("Minimum float positive value: %En", FLT_MIN ); printf("Maximum float positive value: %En", FLT_MAX ); return 0; } When you compile and execute the above program it produces the following result on Linux: Storage size for int : 4 Storage size for float : 4 Minimum float positive value: 1.175494E-38 Maximum float positive value: 3.402823E+38
  • 9. The Void Type: Serial Number : Types and Description 1 Function returns as void : There are various functions in C which do not return value or you can say they return void. A function with no return value has the return type as void. For example void exit (int status); 2 Function arguments as void There are various functions in C which do not accept any parameter. A function with no parameter can accept as a void. For example, int rand(void); 3 Pointers to void A pointer of type void * represents the address of an object, but not its type. For example a memory allocation function void *malloc( size_t size ); returns a pointer to void which can be casted to any data type.
  • 10. Enum [Enumerated] data types:  Syntax: enum identifier {value1, value2,.... Value n};  enum is ” Enumerated Data Type “.  enum is user defined data type  In the above example “identifier” is nothing but the user defined data type .  Value1,Value2,Value3….. etc creates one set of enum values.  Using “identifier” we are creating our variables.
  • 11. Memory Layout  Text or Code Segment Code segment, also known as text segment contains machine code of the compiled program. The text segment of an executable object file is often read-only segment that prevents a program from being accidentally modified.  Data Segments Data segment stores program data. This data could be in form of initialized or uninitialized variables, and it could be local or global. Data segment is further divided into four sub-data segments (initialized data segment, uninitialized or .bss data segment, stack, and heap) to store variables depending upon if they are local or global, and initialized or uninitialized.
  • 12. Memory Layout (Cont.)  Initialized Data or Data Segment Initialized data or simply data segment stores all global, static, constant, and external variables (declared with extern keyword) that are initialized beforehand.  Uninitialized Data or .bss Segment Contrary to initialized data segment, uninitialized data or .bss segment stores all uninitialized global, static, and external variables (declared with extern keyword). Global, external, and static variable are by default initialized to zero. Object file formats distinguish between initialized and uninitialized variables for space efficiency; uninitialized variables do not have to occupy any actual disk space in the object file.
  • 13. Memory Layout (Cont.) Figure 1 : Memory Layout of C Program
  • 14. Memory Layout (Cont.)  Stack Segment Stack segment is used to store all local variables and is used for passing arguments to the functions along with the return address of the instruction which is to be executed after the function call is over. Local pointers are stored in stack segment.  Heap Segment Heap segment is also part of RAM where dynamically allocated variables are stored. In C language dynamic memory allocation is done by using malloc and calloc functions. Global pointers are automatically stored in Heap segment. When some more memory need to be allocated using malloc and calloc function, heap grows upward as shown in Figure 1.
  • 15. Big and Little Endian  Big Endian : In big endian, you store the most significant byte in the smallest address.  Little Endian : In little endian, you store the least significant byte in the smallest address.