SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

Means End Analysis (MEA) in Artificial.pptx
Means End Analysis (MEA) in Artificial.pptxMeans End Analysis (MEA) in Artificial.pptx
Means End Analysis (MEA) in Artificial.pptx
suchita74
 
New microsoft office power point presentation
New microsoft office power point presentationNew microsoft office power point presentation
New microsoft office power point presentation
RamyaRavi26
 
hidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmhidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithm
rajivagarwal23dei
 

Tendances (20)

Naive Bayes Presentation
Naive Bayes PresentationNaive Bayes Presentation
Naive Bayes Presentation
 
Means End Analysis (MEA) in Artificial.pptx
Means End Analysis (MEA) in Artificial.pptxMeans End Analysis (MEA) in Artificial.pptx
Means End Analysis (MEA) in Artificial.pptx
 
Color fundamentals and color models - Digital Image Processing
Color fundamentals and color models - Digital Image ProcessingColor fundamentals and color models - Digital Image Processing
Color fundamentals and color models - Digital Image Processing
 
Machine learning
Machine learningMachine learning
Machine learning
 
Python Scipy Numpy
Python Scipy NumpyPython Scipy Numpy
Python Scipy Numpy
 
-BayesianLearning in machine Learning 12
-BayesianLearning in machine Learning 12-BayesianLearning in machine Learning 12
-BayesianLearning in machine Learning 12
 
Graph coloring problem
Graph coloring problemGraph coloring problem
Graph coloring problem
 
CNN and its applications by ketaki
CNN and its applications by ketakiCNN and its applications by ketaki
CNN and its applications by ketaki
 
Evaluating hypothesis
Evaluating  hypothesisEvaluating  hypothesis
Evaluating hypothesis
 
What is the Expectation Maximization (EM) Algorithm?
What is the Expectation Maximization (EM) Algorithm?What is the Expectation Maximization (EM) Algorithm?
What is the Expectation Maximization (EM) Algorithm?
 
Bayes Classification
Bayes ClassificationBayes Classification
Bayes Classification
 
CGV 18CS62 VTU CSE
CGV 18CS62 VTU CSECGV 18CS62 VTU CSE
CGV 18CS62 VTU CSE
 
New microsoft office power point presentation
New microsoft office power point presentationNew microsoft office power point presentation
New microsoft office power point presentation
 
Computer vision and Open CV
Computer vision and Open CVComputer vision and Open CV
Computer vision and Open CV
 
hidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmhidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithm
 
Heart disease prediction
Heart disease predictionHeart disease prediction
Heart disease prediction
 
5.2 primitive recursive functions
5.2 primitive recursive functions5.2 primitive recursive functions
5.2 primitive recursive functions
 
Morphological Image Processing
Morphological Image ProcessingMorphological Image Processing
Morphological Image Processing
 
Topological Sorting (Decrease and Conquer)
Topological Sorting (Decrease and Conquer)Topological Sorting (Decrease and Conquer)
Topological Sorting (Decrease and Conquer)
 
Histogram processing
Histogram processingHistogram processing
Histogram processing
 

En vedette

En vedette (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
 

Similaire à Memory management of datatypes

C Sharp Jn (1)
C Sharp Jn (1)C Sharp Jn (1)
C Sharp Jn (1)
jahanullah
 

Similaire à 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++
 

Dernier

Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
dharasingh5698
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Dernier (20)

ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 

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.