Data Types

C-Data Types: Data types specify how people enter data into our programs and what type of data is entering. In C it has some predefined set of data types to handle different data that we can use in our program. Each datatype has different storage capacities and ranges.It support 2 data types-

1.Primary data types: This is a fundamental data types in c like integer(int), Float(float), Double(double), character(char) and (void) types.

2.Derived data types: This data type is nothing but it is combinations of fundamental data types. Array, union, structure and pointer are Derived data types. .



Primary Data Types

DATA TYPE MEMORY (BYTES) FORMAT SPECIFIER
short int 2 %hd
unsigned short int 2 %hu
int 4 %d
long int 4 %ld
long long int 8 %lld
unsigned long long int 8 %llu
char 1 %c
float 4 %f
double 8 %lf
long double 12 %Lf

Different data types have different ranges,format specifiers and how much memory it takes to store.This ranges may be different from compiler to compiler. We can use the sizeof() operator to check the size of a variable. See the following C program to check out which data types take how much memory:


#include<stdio.h>
int main()
{
  printf("int takes: %lu bytes.\n",sizeof(int)); // '\n' is for goto new line 
  printf("float takes: %lu bytes.\n",sizeof(float));
  printf("double takes: %lu bytes.\n",sizeof(double));
  printf("char take: %lu byte.\n",sizeof(char));
  return 0;
}
Output:
  int takes: 4 bytes.
  float takes: 4 bytes.
  double takes: 8 bytes.
  char take: 1 byte.
Best way of learing

Self learing is the best learing in the world. Discover yourself first then will get what you are And what you want to do .It will push you for self learing.

Why you need to learn coding?

Coding will play a vital role in one's life . It will help to open a new window of thinking . You can think better way than past . It helps to organise all the thing in better way .