0% found this document useful (0 votes)
1 views

Data type

The document explains data types in C programming, categorizing them into standard and user-defined types. It details various data types including integer, floating point, character, and string, along with their memory sizes and ranges. Additionally, it provides specific examples and characteristics of different integer and floating point types.

Uploaded by

aslamsaira437
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Data type

The document explains data types in C programming, categorizing them into standard and user-defined types. It details various data types including integer, floating point, character, and string, along with their memory sizes and ranges. Additionally, it provides specific examples and characteristics of different integer and floating point types.

Uploaded by

aslamsaira437
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Data type:

The data type specifies the type of data that can be stored in variable. It also defines a set of operations
on data. Every data type have a range of values and requires different amount of memory.it is important
to specify correct data type for the variables in a program so that data can be stored correctly.

Categories of data types:


C language provides two ways to use data types:

Standard data type:


C language defines some standard data types. A data type that is predefined in the c language is
called standard data type.

Example:
Some example of standard data type are int, float, string and char etc.

User-defined data type:


C also allows the user to define his own data types known as user-defined data type.

Types of data type


Integer data type:
Integer constants are numeric values without fraction or decimal point. Integer constant
represent values that are counted. Both positive and negative integer constants are used in c
programs. The minus – is used for negative integer constants if no sign is used the value is
positive by default.
Example:
87 45 -10 -5

Floating point:
Floating point constants are numeric values with fraction or decimal point. Floating point
constant represent value that are measured both positive and negative floating point constant
are used in C programs the minus sign –is used for negative floating point constants if no sign is
used, the value is positive by default.
Example:
Some example of floating point constant are as follows:
50.75 10.22 -13.42
Character data type:
Any character written within single quotation mark is known as character constant. All
alphabetic characters, digits, and special symbols can be used as a character constant.
The maximum length of character constant is 1 character.
Example:
‘A’ ‘n’ ‘=’

String data type:


A collection of characters written in double quotation mark is called string constant. It may
consist of any alphabetic characters, digits , and special symbols.

Example:
“Pakistan” “123”

Types of integer data type


C provides different types of integer data type are as follow:
1. Int data type
int data type is used to represent integer values. An integer variable stores a number
with no fractional part such as 11, 10 and 25 etc. it takes two or four bytes in memory
depending on computer. It’s range is from -32768 to 32767
2. Short data type
Short data type is used to store integer values. It takes two bytes in memory. It’s range
is from -215 to 215-1. It means that the valid values is from -32768 to 32767.
3. Unsigned int data type
Unsigned int data type is used to store only positive integer values. It takes two bytes in
memory. It’s range is from 0 to 216-1. It means that the valid value is from 0 to 65,535.
4. Long data type
Long data type is used to store large integer values it takes 4 bytes in memory. it’s range
is from -231 to 231-1.
5. Unsigned long data type
Unsigned long data type is used to store large positive integer values. It takes 4 byte in
memory. It’s range is from 0 to 232-1.
Data type Size in bytes Range
int 2 -32,768 to 32,767
short 2 -32,768 to 32,767
Unsigned int 2 0 to 65,535
Long 4 -231 to 231-1
Unsigned long 4 0 to 232-1
Types of floating point
C provides different types of floating point are as follow:
1. Float data type
Float data type is used to store large real values. It takes four byte in memory. Its
range is from 3.4*10-38 to 3.4*10+38 . it provides the precision of six decimal
places.
2. Double data type
Double data type is used to store large real values. It takes 8 bytes in memory. Its
range is from 1.7*10-308 to 1.7*10+308. It provide the precision of fifteen decimal
places.
3. Long double data type
Long double data type is used to store very large value. It takes 10 bytes in
memory. Its range is from 1.7*10-4932 to 1.7*10+4932. It provide precision of
nineteen decimal places.

Data type Bytes precision


Float 4 6
Double 8 15
Long double 10 19
Precision
It is a number of digits after decimal point.

Range
It is the exponential power of 10.

Character data type:


Character data type is used to store character values. It takes 1 byte in memory. It is used
to represent a letter, number or punctuation mark and a few other symbols.

You might also like