0% found this document useful (0 votes)
1 views4 pages

Data Types

The document explains data types in programming, categorizing them into primary, derived, and user-defined types. Primary data types include character, integer, float, and void types, each with specific memory sizes and range specifications. Derived data types encompass arrays, structures, unions, and pointers, while user-defined types are created using typedef and enum.

Uploaded by

Rajasomeshwar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views4 pages

Data Types

The document explains data types in programming, categorizing them into primary, derived, and user-defined types. Primary data types include character, integer, float, and void types, each with specific memory sizes and range specifications. Derived data types encompass arrays, structures, unions, and pointers, while user-defined types are created using typedef and enum.

Uploaded by

Rajasomeshwar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

DATA TYPES:

A data type is used to indicate the type of data value stored in a variable.
A data type is essential to identify the storage representation (How much memory
allocates) and the type of operations that can be performed on that data.
There are three classes of data types:
1. Primary Data types
2. Derived Data types
3. User Defined Data types

Primary Data Types


Primary data types are those which are already defined in programming
languages also known in-built data types (predefined datatypes). These data
types are basic building blocks of any programming language
Character Type:
 It is used to store “char” type data (single character)
 Characters stored in 8 bits or 1 byte of memory.
 Character can also be signed and unsigned.
 Its format specifier is %c.
 Its range is -27 to 27-1

Size in Minimal
Data Type Bytes Range Format Specifier
char 1 -27 to 27-1 %c
unsigned cha
r 1 0 to 28-1 %c
signed char 1 -27 to 27-1 %c

Integer Type:
 It is used to store whole numbers. These numbers do not contain the decimal
part.
 integers stored in 16 bits or 2 byte of memory.
 integers can also be signed and unsigned.
 Its format specifier is %d.
 Its range is -215 to 215-1
Size in
Type Bytes Minimal Range Format Specifier
int 2 -(215 - 1) to 215 - 1 %d, %i
unsigned int 2 0 to 216 - 1 %u
signed int 2 -(215 - 1) to 215 - 1 %d, %i
short int 2 -(215 - 1) to 215 - 1 %hd
unsigned short int 2 0 to 216 - 1 %hu
signed short int 2 -(215 - 1) to 215 - 1 %hd
long int 4 -(231 - 1) to 231 - 1 %ld, %li
long long int 8 -(263 - 1) to 263 - 1 %lld, %lli
signed long int 4 -(231 - 1) to 231 - 1 %ld, %li
unsigned long int 4 0 to 232 - 1 %lu
unsigned long long int 8 0 to 264 - 1 %llu

Float Type:

 Floating point number represents a real number with 6 digits precision. It


occupies 4 bytes of memory. Floating point variables are declared by the
keyword float. Its format specifier is %f

 Double floating point data type occupies 8 bytes of memory giving 14 digits
of precision. These are also known as double precision numbers. Variables
are declared by keyword double. . Its format specifier is %lf

 long double refers to a floating point data type that is often more precise
than double precision. . Its format specifier is %Lf
Void type The void type has no values. This is usually used to specify the return
type of functions. The type of the function said to be void when it does not return
any value to the calling function. This is also used for declaring general purpose
pointer called void pointer.

Derived data types Derived datatypes are used in ‘C’ to store a set of data values.
Arrays , Structures , Union and pointer are examples for derived data types.

User-defined data types: The data types defined by the user are known as the
user-defined data types. C provides two identifiers typedef and enum to create new
data type names.

EX:

#include <stdio.h>
void main()
{
char ch='k';
int a=33;
float b= 2.135;
double c=4.8967;
printf("\ncharcter = %c",ch);
printf("\nInteger = %d",a);
printf("\nFloat = %f",b);
printf("\nDouble = %lf",c);
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy