C programming Data types

C programming Data types | C programming tutorials – codingkida

Social Shares
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

C programming Data types

Whenever you create a variable, before that, you tell to the compiler what kind of data you store in that variable with the help of C programming Data types. This gives the compiler the same memory allot from that of memory to the computer. Like, see the given statement below.

For example  –  int age;

The above statement tells the compiler that you are about to store a whole number in age variable. The amount of memory required to store any whole number is equal to the compiler as it allots for this variable. Which are 2 bytes.

Now you can think of how much memory can be lost if there are no C programming Data types. You can waste 2 bytes on the right and you can waste 20 bytes. Thus, the maximum memory limit has already been defined for any type of data you can store. Let’s now try to know about the different types of C programming Data types.

Different C programming Data types

C language supports 3 types of C programming Data types. These are also called primitive types.

  1. Integer
    1. int
    2. short int
    3. long int
    4. signed int
    5. unsigned int
  2. Floating point
    1. float
    2. double
  3. Character
    1. char

you tell to the compiler what kind of data you store in that variable with the help of C programming Data types

Integer Data Types

Integer data types are used to store any whole number (without decimal). Ιnteger types are of 5 types. However, they all store the whole number. But they are classified on the basis of 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
2
-32768 to 32767
unsigned int
2
0 to 65535
Example
long int population = 200000000;

Floating point data types

The floating point data types have been defined to store decimal numbers. Floating point data types are of 2 types. These are classed by the size and base of the range. In float type, you can store up to 7 digits after decimals. Double type can be stored up to 17 digits after decimals.

Data types
 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;

Also Read:

 

Character data types

Character type is used to store a character. These are divided into 2 categories.
Data type
 Size (Bytes)
Range
char
1
-128 to 127
unsigned char
1
0 to 255
Example
char bestlanguage = “C”;

Void Type data type

The Void type is used in situations where you do not have any information about value. It is mostly used with functions. You can use void type in C in these situations.

  1. If your function does not return a value, then you can define its return type void. For example, you can define the function in this way. void myFunction () ;.
  2. If you are not taking any parameters in the function then you can define the void on the right. 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) ;.
  3. If you are not sure that the pointer variable will point to the variable of type, then you can declare its type void. After this, you can point to any variable with the void pointer.

Social Shares
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

7 comments

  1. very informative post about the installation of wordpress blog. This article will cleared all my doubts. You gave a nice explanation about the installation with screenshots. Thanks for sharing this post.

  2. I often visit your blog and have noticed that you
    don’t update it often. More frequent updates will give your page higher authority & rank in google.
    I know that writing content takes a lot of time, but you can always
    help yourself with miftolo’s tools which will shorten the time of creating an article to
    a few seconds.

  3. Hi I AM GOOD IN PHP, JAVASCRIPT BUT NOT AWARE OF PROGRAMMING LANGUAGES. SO IS IT POSSIBLE TO LEARN C LANGUAGE IN ONE WEEK SPENDING FIVE HOURS DAILY. PLEASE GUIDE.

Leave a Reply

Your email address will not be published. Required fields are marked *