Skip to main content

DataTypes


Each variable in C has an associated data type. Each data type requires different amounts of memory and has some specific operations which can be performed over it. Datatype specifies the type of variable
These could be classified into following categories:
  1.           Primitive Datatype : Example - char, int, float, double.
  2.           Non-primitive Datatype: Example - array, structure, pointer.

Following are the examples of some very common data types used in C:
·        char: The most basic data type in C. It stores a single character and requires a single byte of memory in almost all compilers.
·        int: As the name suggests, an int variable is used to store an integer.
·        float: It is used to store decimal numbers (numbers with floating point value) with single precision.
·        double: It is used to store decimal numbers (numbers with floating point value) with double precision.
Different data types also have different ranges upto which they can store numbers. These ranges may vary from compiler to compiler.

Below is list of ranges along with the memory requirement and format specifiers on 32 bit gcc compiler.



Comments

Popular posts from this blog

Reversing digits of a number

#include<stdio.h> #include<conio.h> void main() { clrscr(); int ,num,rev=0,rem; printf("Enter the number:"); scanf("%d",&num); while(num!=0) { rem=num%10; rev=rev*10+rem; num=num/10; } printf("Reverse of given Number is:%d",rev); getch(); }