C programming data type

               C programming data type

In this chapter, you will learn about C programming data type and variable declaration.

Data types are defined by the type of data stored in the variable.

In C programming, the variable or memory location must be declared before use. Likewise, the function has to declare before it can be used.

Data types are defined by variables and functional declarations, usually the size of the data and the type.

C data type
Fundamental data type
Integer type
Floating type
Character type
Derived data type
Arrays
Pointers
Structures
Inumeration
In this chapter we have given more attention to the basic data types. Please visit our Derive data type related section to find out about Derive Data Type.


char-character data type
Char keywords are used to declare a variable of the type of character. For example:

char alphabet = 'a'

Here the alphabet is the character variable and the value of the alphabet 'a'.

Character variable size is 1 byte.


int - integer data type
All positive and negative integers other than decimal (.) Numbers fall into this type. For example, 0, -10, 10 etc.

In C programming, int keywords are used to declare variable types of integer types. For example:

int roll_no; 
Here roll_no is an integer type variable.

At C programming you can declare multiple variables at the same time with a declaration. For example:

int roll_no, age, years; 
The size of int can be 2 bytes (on old computer) or 4 bytes. If your variable size is 4 bytes, then it can take 232 different values. E.g. -231, -231 + 1, ..., - 2, -1, 0, 1, 2, ..., 231-2, 231-1

Similarly, if the int variable size is 2 bytes, it can take 216 numbers of different values ​​between 215 and 215-1. If you want to store small stores from 231-1 ie +2147483647 and from -231 means -2147483648 the program will not run properly.


float - floating type
Floating type variables can contain any real numbers. For example - 3.1416, -5.382, 10.0 etc. You can either use float or double keywords to declare variable types of float type. For example:

float accountBalance;
double bookPrice; 
Here floating type variables are both accountBalance and bookPrice.

The floating value in C programming can also be presented in exponential form. For example:

float normalizationFactor = 22.442e2;


The difference between float and duel
float type double type
The size of the float variable is 4 bytes, double the size of the variable is 8 bytes
Float data type is used for single precision, because of double precision, double data type is used.
The floating point variable's precision 6 digit doubles precedence is 14 digits.

Let's take a look at the data types at a glance. Here the data size is based on 32-bit architecture.

Data type memory size range
char 1 byte-128 to 127
signed char 1 byte-128 to 127
unsigned char 1 byte from 0 to 255
short 2 bytes-32,768 to 32,767
signed short 2 bytes-32,768 to 32,767
unsigned short 2 bytes from 0 to 65,535
int 2 byte-32,768 to 32,767
signed int 2 byte-32,768 to 32,767
unsigned int 2 bytes from 0 to 65,535
short int 2 byte-32,768 to 32,767
signed short int 2 byte-32,768 to 32,767
unsigned short int 2 bytes from 0 to 65,535
long int 4 bytes -2,147,483,648 to 2,147,483,647
signed long int 4 bytes -2,147,483,648 to 2,147,483,647
unsigned long int 4 bytes 0 to 4,294,967,295
float 4 bytes
double 8 bytes
long double 10 bytes

Post a Comment

0 Comments