Data types in C include primary (fundamental) types like integers and floating-point numbers, as well as derived and user-defined types. Primary types include integers of various sizes (char, short, int, long) that can be signed or unsigned, and floating-point types like float, double, and long double. Integer types have size and value ranges that depend on the machine, such as 8-bit char from -128 to 127. Floating-point types have prescribed sizes and precision levels. User can define their own types using typedef to create new type names, or enum to define enumeration types with named values.
1. Data types in C
Enrollment no.170110107014
Kashyap Joshi
Batch:1D07
G H Patel College of Engineering & Technology, V. V.
Nagar,
Academic Year: 2017-18 (Odd Sem.)
Class: First Year Computer Engineering
2110003-COMPUTER PROGRAMMING & UTILIZATION
2. Data types
Basic definition of data type is a data storage
format that can contain a specific type or range
values.
When computer data store in variables, each
variables assigned specific data type.
3. Types of data types
1.Primary (or fundamental) data types.
2.Derived data types.
3.User-defined data types.
4.
5. Integer Types
Integers are the whole numbers with arrange of values
supported by a particular machine.
There are signed integers and unsigned integer. Signed
integer used one bit for sign and other bits for magnitude of
their number. Unsigned integers are always positive. It does
not contain any bit for sign so that it occupies all the bit for
the magnitude of the number.
ANSI C has mainly three class of integer storage ,namely short
integer, integer and long integer, in both signed and
unsigned forms.
6. Size and range of Data types on a 16-bit machine.
Type Size(bits) Range
Char or signed char 8 -128 to 127
Unsigned char 8 0 to 255
Int or signed int 16 -32,768 to 32,767
Unsigned int 16 0 to 65535
Short int or signed short int 8 -128 to 127
Unsigned short int 8 0 to 255
Long int or signed long int 32 -2,147,483,648 to 2,147,483,647
Unsigned long int 32 0 to 4,294,967,295
7. Floating points types
Floating point numbers are stored in 32 bits with 6 digits of
precision .
Floating point numbers are defined in C by the keyword float.
When the accuracy provided by float is not sufficient double data
type is used. It uses 64 bits giving a precision of 14 digits.
When you want to extend more precision you can use the long
double data type . Which uses 80 bits.
8. Size and range of floating –point types.
Type Size(bits) Range
Float 32 3.4E - 38 to 3.4E + 38
Double 64 1.7E – 308 to 1.7E + 308
Long double 80 3.4E – 4932 to 1.1E + 4932
9. Void types
The void type has no values.
The type of the function is said to be void when it does
not return any value to calling function.
It can also play the role of generic type , meaning that it
can represent any of the other standard types.
10. Character types
A single character can be defined as a
character(char) type data.
Characters are usually stored in 8-bits (one byte) of
internal storage.
The qualifier signed and unsigned may be explicitly
applied to char.
While unsigned chars have between 0 and
255,signed chars have values from -128 to 127.
11. Typedef
Using typedef keyword we can define our own user
defined data type.
Syntax:
typedef type identifier;
Example:
typedef int marks;
marks sub1,sub2;