Data Types:
Data types are used to allocate the memory.
Memory used for store the values.
Derived Data Types:
The Data Types which are already derived in c language.
Ex: arrays , pointers…etc.
User Defined Data Types:
The Data Types which are defined by the user called User Defined Data Types.
Ex:
Structures,unions,enum..etc.
Basic Data Types:
Integer:
signed short int / short int / signed int / int :
it is used to allocate the memory of short integers.
it occupies 2 bytes of memory.
+ 10 :
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
1
|
0
|
-10 :
1
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
1
|
0
|
In this first bit is sign bit remaining bits are value bits.
If we enter positive values then sign bit take zero otherwise one.
Range of the values -215 to 215-1.
Data types :
signed short int a, signed short int b…etc.
signed int a, signed int b ...etc.
short int a, short int b ....etc.
int a, int b ...etc.
unsigned short int / unsigned int:
it is to used allocate the memory of positive short integers.
it occupies 2 bytes of memory.
In this all bits are value bits.
Range of the values 0 to 216-1.
Data types :
unsigned short int a, unsigned short int b…etc.
unsigned int a, unsigned int b..etc.
signed long int / long int / long :
it is used to allocate the memory of long integers.
it occupies 4 bytes of memory.
In this first bit is sign bit remaining bits are value bits.
If we enter positive values then sign bit take zero otherwise one.
Range of the values -231 to 231-1.
Data types :
signed long int a, signed long int b …etc.
long int a, long int b ….etc.
long a, long b ….etc.
unsigned long int:
it is used to allocate the memory of positive long integers.
it occupies 4 bytes of memory.
In all bits are value bits.
Range of the values 0 to 232-1.
Data types :
unsigned long int a, unsigned long int b …etc.
Characters :
Char:
Char:
It is used to allocate the memory of characters
It occupy 1 byte of memory.
Range of the values -27 to 27-1.
Data types :
Char a. char b …etc.
float values :
float:
it is used to allocate the memory of floating values or decimal values.
it occupies 4 bytes of memory.
Range of the values 3.4 X 10-34 to 3.4 X 10+34.
Data types :
float a, float b…etc.
double :
it is also used to allocate the memory of floating values or decimal values.
it occupies 8 bytes of memory.
Range of the values 1.7 X 10-304 to 1.7 X 10+304.
Data types :
double a, double b…etc.
long double :
it is also used to allocate the memory of floating values or decimal values.
it occupies 10 bytes of memory.
Range of the values 3.4 X 10-4932 to 1.1 X 10+4932.
Data types :
Long double a, long double b…etc.
Note: 1. float will take 6 decimal places .
2.double will take 14 decimal places .
void:
it can not occupy any memory.
Note1: in c language while
declaring a variable we have to mention which type variable declaring using
data types similarly while displaying a variable we have to mention which type
variable display using Control String or
format specifier.
Ex://Write a Program to Demonstrate datatypes.
clrscr():
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
char b;
float c;
clrscr();
a=56;
b=’c’;
c=45.36;
cout<<a;
cout<<b;
cout<<c;
getch();
}
Output:
56c45.36
|
#include<
iostream.h>
#include<conio.h>
void main()
{
int a;
char b;
float c;
clrscr();
a=56;
b=’c’;
c=45.36;
cout<<”\na=”<<a;
cout<<”\nb=”<<b;
cout<<”\nc=”<<c;
getch();
}
Output:
a=56
b=c
c=45.36
Note: \n for new line
|
it is a predefined function and it is used to clear the screen.
The source code is available in conio.h
conio means console input and out put.
getch():
it is a predefined function and it is used to display the out put at run time and it is not a echo character on the screen.
The source code is available in conio.h
conio means console input and out put.
No comments:
Post a Comment