0% found this document useful (0 votes)
11 views2 pages

Datatypes

Uploaded by

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

Datatypes

Uploaded by

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

Datatypes in C:

* Datatypes are used to represent type of data in proram.


* Also used to create memory location to store data.
* C supports 3 types of datatypes
1.Pre-defined datatypes
2.Derived Datatypes
3.User-Defined datatypes

Pre-defined Datatypes:
* Also called as Premitive datatypes.
* These datatypes will allows us to create a variable that can store one value.
* These datatypes will have fixed size of memory
datatype Type Size Range
char character 1Byte -128 to +127
short integer 1Byte -128 to +127
int Integer 2Bytes -32768 to +32767
long Integer 4Bytes -2^31 to + 2^31-1
float Floating 4Bytes -3.47 E^38 to +3.47 E^38
double Floating 8 Bytes -1.7 E^308 to -+1.7 E^308
long double Floating 10Bytes

Note :datype sizes from above table are based on 16bit system.
If you are using 32bit /64bit system , then
short has 2 Bytes
int has 4Bytes
long double has 16Bytes

Derived Datatypes:
* These datatypes are created by using predefined datatypes.
* Used to increase the capacity of primitive datatypes.
* C supports the following Derived datatypes
1.Arrays: Used to store group of values
2.Functions: used to store group of instructions
3.pointers : used to store and manipulate memory locations

User-defined datatypes:
* These datatypes are created by the programmer.
* These datatypes can store different types of values
* These datatypes have user defined memory size.
* C supports the following User defined datatypes
1.Structures
2.Unions

How to create a variable?

* Variables is a memory location created by using a datatype.


* The following syntax is used to create a variable.
syntax:
datatype variablename;
ex:
int rollno;
int a;
int b;
float x;
float y;
double m,n,p;

* create a variable with the name price that can store a float value.
float price;

* create a variable to store average marks of a student.


float averagemarks;

* create a variable to store the gender (F/M ) of a person


char gender;

* Create three variables to store english, maths and computer marks.

You might also like