SlideShare a Scribd company logo
ASSIGNMENT-II
DATA TYPES
SUBMITTED TO-
Mr. Vikas Somani
SUBMITTED BY-
Harshita Yadav
Bhavyata Sukhwal
What Is Data Type?
• A Data type is a Type of Data.
• Data type is a data storage format that can
contain a specific type or range of values.
• Data types in C refers to an extensive system
used for declaring variable for function of
different types. The type of a variable determines
how much space it occupies in storage and how
the bit pattern stored in interpreted.
A Data Type Is Used to-
• Identify the type of a variable when the
variable is declared.
• Identify the type of the return value of a
function.
• Identify the type of a Parameter expected by
a function.
Classification of Data types
S.N. TYPES & DESCRIPTIONS
1.
Basic Types
They are arithmetic types and are further classified into: (a) integer types
(b) character types and (c) floating-point types.
2.
Enumerated types
They are again arithmetic types and they are used to define variables that
can only assign a certain discrete integer value throughout the program.
3.
The type void
The type specifier void indicates that no value is available.
4.
Derived types
They include (a) pointer types (b) Array types (c) structure types (d) union
types and (e) function types
Basic types
Integer types
• Integers are whole numbers with the wide range of
values that are machine dependent.
• Keyword int is used for declaring the variable with
integer type. For example--
int var1;
• Integer occupies 2 bytes memory space and its value
range limited to -32768 to 32767
• Range of integer is 2^-15 to 2^+15
• Each type is again classified into signed and
unsigned integer.
•The following table provides the details of standard
integer types with their storage sizes and value ranges-
Type Storage size Value range
Int 2 bytes -32,768 to 32,767
unsigned
int
2 bytes 0 to 65,535
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
Character types
• All single character used in programs belong to
character type.
• The range of values that can be stored in a
variable of character data type is -128 to 127.
• The char data type holds exactly 8bits (1 byte).
• Keyword char is used for declaring the variable
with character type. For example--
char var1=h;
Here, var4 is a variable of type character
which is storing a character ‘h’.
Unsigned Char- The unsigned char is a variation of char
type. The size of a variable of unsigned char is also 1 byte.
As the name itself indicates, the range of values that can
be stored in a variable of type unsigned char is “0 to 255”.
CONTINUED…
Floating-Point Type
• All numeric data type items with fractional part
belong to float type.
• The keyword float is used to declare variables of
float type.
float var1;
• A variable of float type requires 4 bytes and the
range of values that can be stored in it, is 3.4e-
38 to 3.4e+38
•The following table provide the details of standard
floating-point types with storage sizes and value ranges
and their precision-
TYPE STORAGE SIZE 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
Enumerated types
• Enumerated types allow us to create our own symbolic names
for a list of related ideas.
• The keyword for enumerated type is enum.
• Enumerated types are used to make a program clearer to
the reader/maintainer of the program.
For example, say we want to write a program that check for
keyboard presses to find if the down arrow or up arrow has
been pressed. We could say: if (press_value==32). 32 is the
computers representation of the down arrow. Or, we could
create our own enumerated type with the key words: down-
arrow and up_arrow. Then we could say: if
(press_value==down_arrow). This second version is much
more readable and understandable to the programmer.
CONTINUED…
The Type Void
• The void type specifies that no value is available. It is
used in two kinds of situations-
S.N. TYPES & DESCRIPTION
1. Function returns as void
There are various functions in C which do not return any value or
you can say they return void. A function with no return value has the
return type as void.
2. Function arguments as void
There are various functions in C which do not accept any parameter.
A function with no parameter can accept a void.
Derived Types
POINTER TYPES
• A pointer is a variable whose value is the address
of another value. i.e. direct address of the
memory location.
• The general form of a pointer variable
declaration is-
datatype *var-name;
• The asterisk * used for multiplication. However,
in this statement the asterisk is being used to
designate a variable as a pointer.
CONTINUED…
• Lets try to understand the concept-
• As shown in the above diagram:
• A normal variable ‘var’ has a memory address of 1001 and holds a value of 50.
• A pointer variable has its own address 2047 but stores 1001, which is the address
of the variable ‘var’.
1001
1001 2047
var
(normal variable)
Ptr
(pointer)
How to declare a pointer?
• A pointer is declared as-
<pointer type> *<pointer-name>
In the above declaration:
1. pointer-type : It specifies the type of pointer. It can be
int, char, float etc. this type specifies the type of variable
whose address this pointer can store.
2. pointer-name : It can be any name specified by the user.
Professionally, there are some coding styles which every code
follows. The pointer names commonly start with ‘P’ or end
with ‘ptr’.
Example :
char *chptr;
ARRAY TYPES
• Array is a kind of data structure that can store a fixed-
size sequential collection of elements of the same type.
• An array is used to store a collection of data, but it is
often more useful to think of an array as a collection of
variables of the same type.
• All arrays consists of contiguous memory locations.
The lowest address corresponds to the first element
and the highest address to the last element.
Numbers[0] Numbers[1] Numbers[2] Numbers[3] …..
First Element Last Element
How to declare Array?
• To declare an array, a programmer specifies the type
of the elements and the number of elements required
by an array as follows-
type arrayName[arraySize];
This is called a single dimensional array. The
arraySize must be an integer constant greater than
zero and type can be any valid C data type. For
example, to declare a 10-element array called balance
of type double, use this statement –
double balance[10];
Here balance is a variable array which is sufficient to hold up to 10
doubles numbers.
STRUCTURE TYPES
• Structure is a user defined data the type available in C
that allows to combine data items of different kinds.
• Structures are used to represent a record.
• To define a structure, you must use struct statement.
The struct statement defines a new data type, with
more than one member.
CONTINUED…
• The format of the struct statement is as follows-
struct [structure tag]
{
member defination;
member defination;
….
member defination;
}
[one or more structure
variables];
UNION TYPES
• A union is a special data type available in C that
allows to store different data types in the same
memory location.
• Unions provide an efficient way of using the same
memory location for multi-purpose.
• To define a union, you must use a union statement.
• The union statement defines a new data type with
more than one member for your program.
CONTINUED…
• The format of the union statement is as follows-
union [union tag]
{
member defination;
member defination;
….
member defination;
}
FUNCTION TYPES
• A function type describes a function that returns a value of a
specified type.
• If the function returns no value, it should be declared as
“function returning void” as follows:
void function1();
• In the following example, the data type for the function is
“function returning int”:
int uppercase(int lc)
{
int uc=lc+0x20;
return uc;
}
data types in C programming

More Related Content

What's hot (20)

PPTX
Constant, variables, data types
Pratik Devmurari
 
PPTX
Data types in c++
Venkata.Manish Reddy
 
PPTX
Pointers in C Programming
Jasleen Kaur (Chandigarh University)
 
PPTX
Function in C program
Nurul Zakiah Zamri Tan
 
PPTX
Programming in c Arrays
janani thirupathi
 
PPTX
Constants and variables in c programming
Chitrank Dixit
 
PPTX
C tokens
Manu1325
 
PPTX
Data Types and Variables In C Programming
Kamal Acharya
 
PDF
Introduction to c++ ppt
Prof. Dr. K. Adisesha
 
PPTX
Pointers in c++
sai tarlekar
 
PPT
File handling in c
David Livingston J
 
PPSX
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
PPTX
Pointer arithmetic in c
sangrampatil81
 
PPT
Array in c
Ravi Gelani
 
PPTX
C keywords and identifiers
Akhileshwar Reddy Ankireddy
 
PPTX
Functions in c language
tanmaymodi4
 
PPTX
Java Data Types
Spotle.ai
 
PPTX
Basic Data Types in C++
Hridoy Bepari
 
PPTX
Control statements in c
Sathish Narayanan
 
Constant, variables, data types
Pratik Devmurari
 
Data types in c++
Venkata.Manish Reddy
 
Pointers in C Programming
Jasleen Kaur (Chandigarh University)
 
Function in C program
Nurul Zakiah Zamri Tan
 
Programming in c Arrays
janani thirupathi
 
Constants and variables in c programming
Chitrank Dixit
 
C tokens
Manu1325
 
Data Types and Variables In C Programming
Kamal Acharya
 
Introduction to c++ ppt
Prof. Dr. K. Adisesha
 
Pointers in c++
sai tarlekar
 
File handling in c
David Livingston J
 
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
Pointer arithmetic in c
sangrampatil81
 
Array in c
Ravi Gelani
 
C keywords and identifiers
Akhileshwar Reddy Ankireddy
 
Functions in c language
tanmaymodi4
 
Java Data Types
Spotle.ai
 
Basic Data Types in C++
Hridoy Bepari
 
Control statements in c
Sathish Narayanan
 

Similar to data types in C programming (20)

PPTX
Programming Fundamentals lecture 6
REHAN IJAZ
 
PPTX
Data types
Dr. Rupinder Singh
 
PPTX
TAPASH kumar das its my college pptasjhk
destroyer7992
 
PPTX
Datatypes in c
CGC Technical campus,Mohali
 
PPTX
data types in c programming language in detail
atulk4360
 
PPT
C language Unit 2 Slides, UPTU C language
Anurag University Hyderabad
 
PDF
C programming session8
Keroles karam khalil
 
PDF
C programming session8
Keroles karam khalil
 
PPSX
Data type
Frijo Francis
 
PPT
Unit 1 Built in Data types in C language.ppt
pubgnewstate1620
 
PPTX
C PROGRAMMING LANGUAGE
PRASANYA K
 
PPTX
Lecture 2
marvellous2
 
PPTX
COM1407: Variables and Data Types
Hemantha Kulathilake
 
PPT
Data Handling
Praveen M Jigajinni
 
PPTX
C data types, arrays and structs
Saad Sheikh
 
PPT
C Programming Intro.ppt
LECO9
 
PPTX
Data Types in C language
AbdulKabeer50
 
PPT
C++ data types
pratikborsadiya
 
PPTX
Datatypes
Ram Sandeep
 
PPTX
Pointers in c v5 12102017 1
tanmaymodi4
 
Programming Fundamentals lecture 6
REHAN IJAZ
 
Data types
Dr. Rupinder Singh
 
TAPASH kumar das its my college pptasjhk
destroyer7992
 
data types in c programming language in detail
atulk4360
 
C language Unit 2 Slides, UPTU C language
Anurag University Hyderabad
 
C programming session8
Keroles karam khalil
 
C programming session8
Keroles karam khalil
 
Data type
Frijo Francis
 
Unit 1 Built in Data types in C language.ppt
pubgnewstate1620
 
C PROGRAMMING LANGUAGE
PRASANYA K
 
Lecture 2
marvellous2
 
COM1407: Variables and Data Types
Hemantha Kulathilake
 
Data Handling
Praveen M Jigajinni
 
C data types, arrays and structs
Saad Sheikh
 
C Programming Intro.ppt
LECO9
 
Data Types in C language
AbdulKabeer50
 
C++ data types
pratikborsadiya
 
Datatypes
Ram Sandeep
 
Pointers in c v5 12102017 1
tanmaymodi4
 
Ad

Recently uploaded (20)

PPTX
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PDF
Introduction presentation of the patentbutler tool
MIPLM
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
PPTX
Difference between write and update in odoo 18
Celine George
 
PDF
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
PDF
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
epi editorial commitee meeting presentation
MIPLM
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PDF
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
Controller Request and Response in Odoo18
Celine George
 
Introduction presentation of the patentbutler tool
MIPLM
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
Difference between write and update in odoo 18
Celine George
 
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
epi editorial commitee meeting presentation
MIPLM
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
Ad

data types in C programming

  • 1. ASSIGNMENT-II DATA TYPES SUBMITTED TO- Mr. Vikas Somani SUBMITTED BY- Harshita Yadav Bhavyata Sukhwal
  • 2. What Is Data Type? • A Data type is a Type of Data. • Data type is a data storage format that can contain a specific type or range of values. • Data types in C refers to an extensive system used for declaring variable for function of different types. The type of a variable determines how much space it occupies in storage and how the bit pattern stored in interpreted.
  • 3. A Data Type Is Used to- • Identify the type of a variable when the variable is declared. • Identify the type of the return value of a function. • Identify the type of a Parameter expected by a function.
  • 4. Classification of Data types S.N. TYPES & DESCRIPTIONS 1. Basic Types They are arithmetic types and are further classified into: (a) integer types (b) character types and (c) floating-point types. 2. Enumerated types They are again arithmetic types and they are used to define variables that can only assign a certain discrete integer value throughout the program. 3. The type void The type specifier void indicates that no value is available. 4. Derived types They include (a) pointer types (b) Array types (c) structure types (d) union types and (e) function types
  • 6. Integer types • Integers are whole numbers with the wide range of values that are machine dependent. • Keyword int is used for declaring the variable with integer type. For example-- int var1; • Integer occupies 2 bytes memory space and its value range limited to -32768 to 32767 • Range of integer is 2^-15 to 2^+15 • Each type is again classified into signed and unsigned integer.
  • 7. •The following table provides the details of standard integer types with their storage sizes and value ranges- Type Storage size Value range Int 2 bytes -32,768 to 32,767 unsigned int 2 bytes 0 to 65,535 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
  • 8. Character types • All single character used in programs belong to character type. • The range of values that can be stored in a variable of character data type is -128 to 127. • The char data type holds exactly 8bits (1 byte). • Keyword char is used for declaring the variable with character type. For example-- char var1=h; Here, var4 is a variable of type character which is storing a character ‘h’.
  • 9. Unsigned Char- The unsigned char is a variation of char type. The size of a variable of unsigned char is also 1 byte. As the name itself indicates, the range of values that can be stored in a variable of type unsigned char is “0 to 255”. CONTINUED…
  • 10. Floating-Point Type • All numeric data type items with fractional part belong to float type. • The keyword float is used to declare variables of float type. float var1; • A variable of float type requires 4 bytes and the range of values that can be stored in it, is 3.4e- 38 to 3.4e+38
  • 11. •The following table provide the details of standard floating-point types with storage sizes and value ranges and their precision- TYPE STORAGE SIZE 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
  • 13. • Enumerated types allow us to create our own symbolic names for a list of related ideas. • The keyword for enumerated type is enum. • Enumerated types are used to make a program clearer to the reader/maintainer of the program. For example, say we want to write a program that check for keyboard presses to find if the down arrow or up arrow has been pressed. We could say: if (press_value==32). 32 is the computers representation of the down arrow. Or, we could create our own enumerated type with the key words: down- arrow and up_arrow. Then we could say: if (press_value==down_arrow). This second version is much more readable and understandable to the programmer. CONTINUED…
  • 15. • The void type specifies that no value is available. It is used in two kinds of situations- S.N. TYPES & DESCRIPTION 1. Function returns as void There are various functions in C which do not return any value or you can say they return void. A function with no return value has the return type as void. 2. Function arguments as void There are various functions in C which do not accept any parameter. A function with no parameter can accept a void.
  • 17. POINTER TYPES • A pointer is a variable whose value is the address of another value. i.e. direct address of the memory location. • The general form of a pointer variable declaration is- datatype *var-name; • The asterisk * used for multiplication. However, in this statement the asterisk is being used to designate a variable as a pointer.
  • 18. CONTINUED… • Lets try to understand the concept- • As shown in the above diagram: • A normal variable ‘var’ has a memory address of 1001 and holds a value of 50. • A pointer variable has its own address 2047 but stores 1001, which is the address of the variable ‘var’. 1001 1001 2047 var (normal variable) Ptr (pointer)
  • 19. How to declare a pointer? • A pointer is declared as- <pointer type> *<pointer-name> In the above declaration: 1. pointer-type : It specifies the type of pointer. It can be int, char, float etc. this type specifies the type of variable whose address this pointer can store. 2. pointer-name : It can be any name specified by the user. Professionally, there are some coding styles which every code follows. The pointer names commonly start with ‘P’ or end with ‘ptr’. Example : char *chptr;
  • 20. ARRAY TYPES • Array is a kind of data structure that can store a fixed- size sequential collection of elements of the same type. • An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. • All arrays consists of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element. Numbers[0] Numbers[1] Numbers[2] Numbers[3] ….. First Element Last Element
  • 21. How to declare Array? • To declare an array, a programmer specifies the type of the elements and the number of elements required by an array as follows- type arrayName[arraySize]; This is called a single dimensional array. The arraySize must be an integer constant greater than zero and type can be any valid C data type. For example, to declare a 10-element array called balance of type double, use this statement – double balance[10]; Here balance is a variable array which is sufficient to hold up to 10 doubles numbers.
  • 22. STRUCTURE TYPES • Structure is a user defined data the type available in C that allows to combine data items of different kinds. • Structures are used to represent a record. • To define a structure, you must use struct statement. The struct statement defines a new data type, with more than one member.
  • 23. CONTINUED… • The format of the struct statement is as follows- struct [structure tag] { member defination; member defination; …. member defination; } [one or more structure variables];
  • 24. UNION TYPES • A union is a special data type available in C that allows to store different data types in the same memory location. • Unions provide an efficient way of using the same memory location for multi-purpose. • To define a union, you must use a union statement. • The union statement defines a new data type with more than one member for your program.
  • 25. CONTINUED… • The format of the union statement is as follows- union [union tag] { member defination; member defination; …. member defination; }
  • 26. FUNCTION TYPES • A function type describes a function that returns a value of a specified type. • If the function returns no value, it should be declared as “function returning void” as follows: void function1(); • In the following example, the data type for the function is “function returning int”: int uppercase(int lc) { int uc=lc+0x20; return uc; }