SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
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;
}
cassignmentii-170424105623.pdf

Weitere ähnliche Inhalte

Ähnlich wie cassignmentii-170424105623.pdf

Ähnlich wie cassignmentii-170424105623.pdf (20)

Datatypes
DatatypesDatatypes
Datatypes
 
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++
 
variablesfinal-170820055428 data type results
variablesfinal-170820055428 data type resultsvariablesfinal-170820055428 data type results
variablesfinal-170820055428 data type results
 
CS4443 - Modern Programming Language - I Lecture (2)
CS4443 - Modern Programming Language - I  Lecture (2)CS4443 - Modern Programming Language - I  Lecture (2)
CS4443 - Modern Programming Language - I Lecture (2)
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introduction
 
Data Types in C language
Data Types in C languageData Types in C language
Data Types in C language
 
Data types in C
Data types in CData types in C
Data types in C
 
C96e1 session3 c++
C96e1 session3 c++C96e1 session3 c++
C96e1 session3 c++
 
Chap 2(const var-datatype)
Chap 2(const var-datatype)Chap 2(const var-datatype)
Chap 2(const var-datatype)
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
 
Datatypes in c
Datatypes in cDatatypes in c
Datatypes in c
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
 
C presentation! BATRA COMPUTER CENTRE
C presentation! BATRA  COMPUTER  CENTRE C presentation! BATRA  COMPUTER  CENTRE
C presentation! BATRA COMPUTER CENTRE
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt
 
Csc240 -lecture_4
Csc240  -lecture_4Csc240  -lecture_4
Csc240 -lecture_4
 
C language
C languageC language
C language
 
C#
C#C#
C#
 
LEARN C# PROGRAMMING WITH GMT
LEARN C# PROGRAMMING WITH GMTLEARN C# PROGRAMMING WITH GMT
LEARN C# PROGRAMMING WITH GMT
 
datatypes-200723165518 (1).pptx
datatypes-200723165518 (1).pptxdatatypes-200723165518 (1).pptx
datatypes-200723165518 (1).pptx
 

Kürzlich hochgeladen

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
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
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
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
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
 
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
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
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
 
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
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
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
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 

Kürzlich hochgeladen (20)

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, ...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
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
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
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
 
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
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
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
 
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
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
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
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 

cassignmentii-170424105623.pdf

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