Data Types in C Programming


C data types are defined as the data storage format that a variable can store a data to perform a specific operation.Data types are used to define a variable before to use in a program.


List of Data Types in C Programming

Data Type in C Programming

Integer Datatype

An integer is a whole number that can be positive, negative, or zero.

Data Type Memory Range Format Specifier
short int 2 -32768 to 32767 %hd
unsigned short int 2 0 to 65535 %hu
unsigned int 4 0 to 4294967295 %u
int 4 -2147483648 to 2147483647 %d
long int 4 -2147483648 to 2147483647 %ld
unsigned long int 4 0 to 4294967295 %lu
long long int 8 -9223372036854775808 To 9223372036854775807 %lld
unsigned long long int 8 0 to 18446744073709551615 %llu

Character Data Type in C Programming

Character is a data type that holds one character (letter, number, etc.) of data. It must be enclosed with single quotes. e.g. 'A', '4', or '#'

Data Type Memory Range Format Specifier
char or signed char 1 -128 to 127 %c
unsigned char 1 0 to 255 %c

Floating Point Data Type in C Programming

Float is a shortened term for floating point.

Data Type Memory Range Format Specifier
float 4 3.4E-38 to 3.4E+38 %f
double 8 1.7E-308 to 1.7E+308 %lf
long double 12 3.4E-4932 to 1.1E+4932 %lf

Program to Find the maximum and minimum values to Store in a Datatypes



Source Code

#include<stdio.h>
#include<limits.h>
#include<float.h>
int main()
{
  //Integer
  printf("\nShort int %u Bytes %d To %d",sizeof(short int),SHRT_MIN,SHRT_MAX);
  printf("\nunsigned short int %u Bytes 0 To %d",sizeof(unsigned short int),USHRT_MAX);
  printf("\nunsigned int %u Bytes 0 To %u",sizeof(unsigned int),UINT_MAX);
  printf("\nint %u Bytes %d To %d",sizeof(int),INT_MIN,INT_MAX);
  printf("\nlong int %u Bytes %ld To %ld",sizeof(long int),LONG_MIN,LONG_MAX);
  printf("\nunsigned long int %u Bytes 0 To %u",sizeof(unsigned long int),ULONG_MAX);
  printf("\nlong long int %u Bytes %lld To %lld",sizeof(long long int),LONG_LONG_MIN,LONG_LONG_MAX);
  printf("\nunsigned long long int %u Bytes 0 To %llu \n\n",sizeof(unsigned long long int),ULONG_LONG_MAX);
  //Character
  printf("\nCharacter %u Bytes %d To %d",sizeof(char),CHAR_MIN,CHAR_MAX);
  printf("\nCharacter %u Bytes 0 To %d\n\n",sizeof(unsigned char),UCHAR_MAX);
  //Float
  printf("\nFloat %u Bytes",sizeof(float));
  printf("\nDouble %u Bytes",sizeof(double));
  printf("\nLong Double %u Bytes\n\n",sizeof(long double));
  return 0;
}
To download raw file Click Here

Output

Short int 2 Bytes -32768 To 32767
unsigned short int 2 Bytes 0 To 65535
unsigned int 4 Bytes 0 To 4294967295
int 4 Bytes -2147483648 To 2147483647
long int 4 Bytes -2147483648 To 2147483647
unsigned long int 4 Bytes 0 To 4294967295
long long int 8 Bytes -9223372036854775808 To 9223372036854775807
unsigned long long int 8 Bytes 0 To 18446744073709551615

Character 1 Bytes -128 To 127
Character 1 Bytes 0 To 255

Float 4 Bytes
Double 8 Bytes
Long Double 12 Bytes

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C


Learn All in Tamil © Designed & Developed By Tutor Joes