C Programming Language Class 3 : C Data Types

C Programming Language Class 3 : C Data Types


C Programming Language Class 3 : C Data Types

Data types in any of the language means that what are the various type of data the variables can have in that particular language. Whenever a variable is declared it becomes necessary to define data type that what will be the type of data that variable can hold.

Mainly there are two types of data types:
1. Primary Data Type
2. Secondary Data Type

Primary Data Type : character, integer, float, double, void

Secondary Data Type : arrays, pointer, structures, union, enum

C Programming Language Class 3 : C Data Types
C data types

C language also supports the wide range of data type like :

Data type Keyword Bits Range
integer int 16 -32768 to 32767
long integer long 32 -4294967296 to 4294967295
short integer short 8 -128 to 127
unsigned integer unsigned 16 0 to 65535
character char 8 0 to 255
floating point float 32 approximately 6 digits of precision
double floating point double 64 approximately 12 digits of precision


The data type can also be of signed & unsigned. If the unsigned notation is used then the range becomes just double. The long, signed & unsigned notations are also called qualities.

Sample Data types program :

// data types program example
using namespace std;
int main()

    int a = 3000; // positive integer data type
    float b = 4.5345; // float data type
    char c = 'A'; // char data type
    long d = 31456; // long positive integer data type
    long e = -31456; // long -ve integer data type
    int f = -145; // -ve integer data type
    short g = 120; // short +ve integer data type
    short h = -120; // short -ve integer data type
    double i = 5.1234567890; // double float data type
    float j = -3.24; // float data type



Enum Data Type

This is an user defined data type having finite set of enumeration constants. The keyword ‘enum‘ is used to create enumerated data type.


enum [data_type] {const1, const2, …., const n};

Example Code:

enum mca(software, internet, seo);



It is used to create new data type. But it is commonly used to change existing data type with another name.


typedef [data_type] synonym;

typedef [data_type] new_data_type;


Example Code:

typedef int integer;
integer rollno;


Thats all for today, tomorrow we will learn about C variables and constants.