2 Data Types
2 Data Types
2 Data Types
1. Primitive
2. Derived
3. User Defined
Ranges of Data Types
Integer Data Type
Integer data type allows a variable to store
numeric values.
“int” keyword is used to refer integer data
type.
The storage size of int data type is 2 bytes.
int (2 byte) can store values from -32,768 to
+32,767
If you want to use the integer value that
crosses the above limit, you can go for “long
int” for which the limits are very high.
General Syntax to declare
int
void main()
{
int a,b; // Here we have declared 2
integers
}
void main()
{
char a,b; // Here we have declared 2
characters
}
void main()
{
float a,b; // Here we have declared 2
float variables
}
void main()
{
double a,b; // Here we have declared 2
double variables
}
General Syntax
void main()
{
}
Enum
An enum is a keyword, it is an user
defined data type. All properties of
integer are applied on Enumeration data
type so size of the enumerator data type
is 2 byte. It work like the Integer.
It is used for creating an user defined
data type of integer. Using enum we can
create sequence of integer constant
value.
Syntax of enum
enum tagname {value1, value2,
value3,....};
int today;
enum week{ sun,mon,tue,wed,thu,fri,sat};
clrscr();
today = wed;
printf("Day %d",today+1);
getch();
}