Introduction to Data types
A Data type is nothing but types of data.For example int,char,float,double etc..A variable declared with specific data type(int=a;or float =a;).The type of variable decide how much space is occupied in memory.
All data type is derived by following categories:-
1.Primitive data type or Fundamental Data type.
2.Derived data type.
3.User defined data type.
![]() |
Fig 1:Types of Data Type |
Note: Apart from these basic data type in C language further more data types available which has defined inside header files which we will be discuss asap.
Data Type Range
Program #1
How to find size of data type in C?
#include<stdio.h>
#nclude<conio.h>
void main(void)
{
printf("Size:%d",sizeof(int));
getch();
}
Program #2
#include<stdio.h>
#nclude<float.h>
void main(void)
{
printf("Size:%d byte",sizeof(float));
printf("Float Min_Range:%E \n",FLT_MIN);
printf("Float Max_Range:%E \n",FLT_MAX);
printf("Precision Val:%d \n",FLT_DIG);
getch();
}
Answer:
Size: 4 byte
Float Min_Range: 1.175494E-38
Float Max_Range: 3.402823E+38
Precision Val: 6
Program #3
what is the output?
Assume a variable is declared as signed int a =32767..if you increment a what will be the output?
#include<stdio.h>
void main(void)
{
int a=32767; // default int consider as signed int
a++;
printf("%d",a);
getch();
}
Answer: -32768
Description : In following diagram describe circle diagram of data type range.so when you increment 32767 it will give you -32768 ..see below pic
Signed Integer Range:
![]() |
Fig 1: Signed integer Circle range |
Unsigned Integer Range:
![]() |
Fig 1: Unsigned Integer Circle Range |
No comments:
Post a Comment