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

PPTX
Data types in C
Tarun Sharma
 
PPTX
Data types
Zahid Hussain
 
PPT
Basics of C programming
avikdhupar
 
PPTX
History of Computer
Nikki Paccial
 
PPTX
Data types in C language
kashyap399
 
PPT
Array in c
Ravi Gelani
 
PPT
Variables in C Programming
programming9
 
PPSX
Break and continue
Frijo Francis
 
Data types in C
Tarun Sharma
 
Data types
Zahid Hussain
 
Basics of C programming
avikdhupar
 
History of Computer
Nikki Paccial
 
Data types in C language
kashyap399
 
Array in c
Ravi Gelani
 
Variables in C Programming
programming9
 
Break and continue
Frijo Francis
 

What's hot (20)

PPTX
Tokens in C++
Mahender Boda
 
PPTX
Functions in C
Kamal Acharya
 
PPTX
Union in C programming
Kamal Acharya
 
PPT
structure and union
student
 
PPTX
Functions in c++
Rokonuzzaman Rony
 
PPTX
Strings in C
Kamal Acharya
 
PPTX
Data types in c++
Venkata.Manish Reddy
 
PPTX
C Tokens
Ripon Hossain
 
PPTX
Constant, variables, data types
Pratik Devmurari
 
PPTX
C language ppt
Ğäùråv Júñêjå
 
PPT
Class and object in C++
rprajat007
 
PPT
constants, variables and datatypes in C
Sahithi Naraparaju
 
PPTX
Functions in c language
tanmaymodi4
 
PPT
Strings
Mitali Chugh
 
PPTX
classes and objects in C++
HalaiHansaika
 
PPTX
C++ Overview PPT
Thooyavan Venkatachalam
 
PDF
Strings in python
Prabhakaran V M
 
PPTX
Programming in c Arrays
janani thirupathi
 
PPTX
Pointer in c
lavanya marichamy
 
PPTX
Data Type in C Programming
Qazi Shahzad Ali
 
Tokens in C++
Mahender Boda
 
Functions in C
Kamal Acharya
 
Union in C programming
Kamal Acharya
 
structure and union
student
 
Functions in c++
Rokonuzzaman Rony
 
Strings in C
Kamal Acharya
 
Data types in c++
Venkata.Manish Reddy
 
C Tokens
Ripon Hossain
 
Constant, variables, data types
Pratik Devmurari
 
C language ppt
Ğäùråv Júñêjå
 
Class and object in C++
rprajat007
 
constants, variables and datatypes in C
Sahithi Naraparaju
 
Functions in c language
tanmaymodi4
 
Strings
Mitali Chugh
 
classes and objects in C++
HalaiHansaika
 
C++ Overview PPT
Thooyavan Venkatachalam
 
Strings in python
Prabhakaran V M
 
Programming in c Arrays
janani thirupathi
 
Pointer in c
lavanya marichamy
 
Data Type in C Programming
Qazi Shahzad Ali
 
Ad

Similar to data types in C programming (20)

PPT
Data Handling
Praveen M Jigajinni
 
PPT
C++ data types
pratikborsadiya
 
PPTX
Concept of c data types
Manisha Keim
 
PPTX
Concept Of C++ Data Types
k v
 
PPTX
Chapter 2.datatypes and operators
Jasleen Kaur (Chandigarh University)
 
PPTX
Data types
Nokesh Prabhakar
 
PPTX
C PROGRAMMING LANGUAGE
PRASANYA K
 
PPTX
Data types
Sachin Satwaskar
 
PPT
Datatypes
ZTE Nepal
 
PPTX
Variables in C++, data types in c++
Neeru Mittal
 
PDF
variablesfinal-170820055428 data type results
atifmugheesv
 
PPTX
CS4443 - Modern Programming Language - I Lecture (2)
Dilawar Khan
 
PPTX
Module 1:Introduction
nikshaikh786
 
PPTX
Data Types in C language
AbdulKabeer50
 
PPTX
TAPASH kumar das its my college pptasjhk
destroyer7992
 
PDF
PROGRAMMING IN C UNIT II.pdfFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
dinesh620610
 
PPTX
Data types in C
Ansh Kashyap
 
PPTX
Basic C programming Language - Unit 1.pptx
Margaret Mary
 
PPT
C96e1 session3 c++
Mukund Trivedi
 
Data Handling
Praveen M Jigajinni
 
C++ data types
pratikborsadiya
 
Concept of c data types
Manisha Keim
 
Concept Of C++ Data Types
k v
 
Chapter 2.datatypes and operators
Jasleen Kaur (Chandigarh University)
 
Data types
Nokesh Prabhakar
 
C PROGRAMMING LANGUAGE
PRASANYA K
 
Data types
Sachin Satwaskar
 
Datatypes
ZTE Nepal
 
Variables in C++, data types in c++
Neeru Mittal
 
variablesfinal-170820055428 data type results
atifmugheesv
 
CS4443 - Modern Programming Language - I Lecture (2)
Dilawar Khan
 
Module 1:Introduction
nikshaikh786
 
Data Types in C language
AbdulKabeer50
 
TAPASH kumar das its my college pptasjhk
destroyer7992
 
PROGRAMMING IN C UNIT II.pdfFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
dinesh620610
 
Data types in C
Ansh Kashyap
 
Basic C programming Language - Unit 1.pptx
Margaret Mary
 
C96e1 session3 c++
Mukund Trivedi
 
Ad

Recently uploaded (20)

PPTX
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
PPTX
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
PPTX
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PPTX
Understanding operators in c language.pptx
auteharshil95
 
PDF
Exploring-Forces 5.pdf/8th science curiosity/by sandeep swamy notes/ppt
Sandeep Swamy
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PDF
7.Particulate-Nature-of-Matter.ppt/8th class science curiosity/by k sandeep s...
Sandeep Swamy
 
PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PDF
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PDF
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
PPTX
Strengthening open access through collaboration: building connections with OP...
Jisc
 
PDF
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PPTX
Congenital Hypothyroidism pptx
AneetaSharma15
 
DOCX
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PDF
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
Understanding operators in c language.pptx
auteharshil95
 
Exploring-Forces 5.pdf/8th science curiosity/by sandeep swamy notes/ppt
Sandeep Swamy
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
7.Particulate-Nature-of-Matter.ppt/8th class science curiosity/by k sandeep s...
Sandeep Swamy
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
Strengthening open access through collaboration: building connections with OP...
Jisc
 
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
Congenital Hypothyroidism pptx
AneetaSharma15
 
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 

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; }