DATA TYPES IN C LANGUAGE | EXPLANATION OF C LANGUAGE

Data Types in C language

The type of data that can be kept in a variable in a programming language is called data type. There are many types of data types such as integer, character, string, real, etc. which are kept in a variable in any programming language. All these types are known as data types.


In normal terms, when we declare a variable during programming, then you have to tell the compiler what type of data you want to store in the variable, the compiler provides the same amount of memory from the computer memory. With the ability to divide data into different types of language, you can easily work with complex programs. There are two reasons to know the difference between different types of data, 


which is as follows -


  • The compiler, which translates the program into object code (as 0 and 1), can use the appropriate internal representation for each data type.
  • While designing a program, programmers can use the right operator to operate on data of every type.

BASIC DATA TYPES


DATA TYPES IN C LANGUAGE | EXPLANATION OF C LANGUAGE


C Language supports the following data types.


There is any programming language like - c, c ++, java, PHP, etc. Some data types are important for programming. Whenever we create a program, we need some memory to run that program on the computer. And we can take this memory only with the help of data type, the data type itself tells which type of value it is. We have come to know in an earlier post what the variable is and how to declare it. Declaring the variable only provides memory for the program and requires a data type to declare these variables.


Fundamental Data type -: Primary data type is also called Fundamental data type. They are of the following types.


  • int
  • char
  •  float
  •  string

All the "C" compilers support the five major primary data types named int, char, float, double, and string.



Integer Type

Floating point

Character Types

Int

short int

long int

signed int

unsigned int

float

double

Char



Integer


Integer types are used to store any whole number (a number without a decimal). There are 5 types of Integer types. However, they all store complete numbers. But they are divided based on memory size and range.



Data type

Size  (Bytes)

Range

int

2

-32768 to 32767

short int

1

-128 to 127

long int

4

-2,147,483,648 to 2,147,483,647

signed int (for negative values)

2

-32768 to 32767

unsigned int

2

0 to 65535



Example : long int population = 200000000;


Floating point


The floating-point data type is defined to store numbers with decimals. Floating-point data types are of 2 types. They are divided based on size and range. In float type, you can store up to 7 digits after the decimal. Whereas up to 17 digits after decimal can be stored in double type.



Data type

Size  (Bytes)

Range

float

4

3.4E-38 to 3.4E + 38

double

8

1.7E-308 to 1.7E + 308


Example : double balance=810.12354984;


Character Type


Character Type is used to store a character. They are divided into 2 categories.



Data type

Size  (Bytes)

Range

char

1

-128 to 127

unsigned char

1

0 to 255


Example: char best language = “C”;


Void type


The void type is used in situations when you have no idea about the value. It is mostly used with functions. You can use Void type in C in these situations.


  • If your function does not return any value, you define its return type Void. For example, you can define a function like this. void myFunction ();.
  • If you are not taking any parameters in the function, then you can define Void there. Void type shows that no argument is taken in this function. For example, you can pass Void as a parameter in this way. int myFunction (void);.
  • If you are not sure which type of variable will point to the variable then you can declare its type Void. After this, you can point to any variable with a Void pointer.
AKASH TIMES

I AM AN ENGINEER BY PROFESSION BUT BLOGGER IS MY OLD DAYS DREAM TO CREATE MY OWN SITE FOR THOSE WHO ARE CURIOUS ABOUT MY BIRTHPLACE THEN I AM COMING FROM (INDIA). THE CURRENT CITY LIVES IN NAVI MUMBAI, INDIA

Post a Comment

IF YOU HAVE ANY PROBLEM PLEASE FELL FREE TO CONTACT US BY - AKASH TIMES

PREVIOUS POST NEXT POST