Data Types in c

Programming languages or concepts
0

 

Data Types in C


in this tutorial we are learn about Data types present in C programming Language.
A data type specifies the type of data that a variable can store such as integer, floating, character, etc.

In C programming, data types are declarations for variables. This determines the type and size of data associated with variables. For example,

int firstVar;

Here, firstVar is a variable of int (integer) type. The size of int is 4 bytes.


The types in C can be classified as follows
Basic Types :

They are arithmetic types and are further classified into: (a) integer types and (b) floating-point types.
Ex: int, char, float, double

Enumerated types :

They are again arithmetic types and they are used to define variables that can only assign certain discrete integer values throughout the program.
Ex: enum.

The type void :

The type specifier void indicates that no value is available.

Ex:  void.

Derived types :

They include (a) Pointer types, (b) Array types, (c) Structure types, (d) Union types and (e) Function types.

Data types are divided into two groups:


Primitive data types - includes byte, short, int, long, float, double, boolean and char
Non-primitive data types - such as String, Arrays and Classes (you will learn more about these in a later chapter)


int :

Integers are whole numbers that can have both zero, positive and negative values but no decimal values. For example, 0, 2,-3, 10.

We can use int for declaring an integer variable.

int num;
Here, id is a variable of type integer.

float and double :

float and double are used to hold real numbers.

Ex. 
float percentage;
double MRP;

char :

Keyword char is used for declaring character type variables. For example,

char test = 'h';


Post a Comment

0Comments

Post a Comment (0)
close