Data Types In C
Mainly there are two types of data types:
1. Simple or primivitive.
2. Compound or structured or derived.
An primitive data is fundamental unit of information which cannot be broken down further.
Simple: integers, floats, characters, pointers.
Derived data is made up of one or more simple data items.
Compound : arrays, structures, unions
.Integers in C
Integers stores numeric value without a decimal point in the system memory.
Types Bytes required
Short int 2
Int 4
Long int 4
Floats in C
It stores numeric values with decimal point in the system memory.
Types Bytes required
Float 4
Double 8
Long double 8
Characters in C
Characters is data type which stores an element of machine character set.
The character set is used is usually ASCII set, it is denoted by char. It takes only one byte. Also singed and unsigned both occupy one byte having different ranges.
The primary data type themselves could be of several types. for example Character char could be Unsigned char. or Signed char. The values stores in the given integer variables will always be positive. for example we can declare a variables to be unsigned.
unsigned int num_student,
The range of integer values is -32768 to +32767 value s for a 16 bit OS to range 0 to 65535.char ch =A; where ASCII value of A is 65.
Characters Types, Size in Bytes and Range
Type Name Bytes Range
------------- 16 bit system -------------
char 1 -128 to 127
signed char 1 -128 to 127
unsigned char 1 0 to 255
short 2 -32,768 to 32,767
unsigned short 2 0 to 65,535
int 2 -32,768 to 32,767
unsigned int 2 0 to 65,535
long 4 -2,147,483,648 to 2,147,483,647
unsigned long 4 0 to 4,294,967,295
float 4 3.4E+/-38 (7 digits)
double 8 1.7E+/-308 (15 digits)
long double 10 1.2E+/-4932 (19 digits)
Variable:
A variable is a meaningful name of data storage location in computer memory. When using a variable you refer to memory address of computer.
For ex:
int a =10; // initialization
int a // declaration
No comments:
Post a Comment