C Programming Data Types : Part 1

Navigation : Home / , / Article : C Programming Data Types : Part 1

C Programming Data Types : Part 1

Monday, April 16, 2012 | No Comments | Labels : ,

C has concept of data type which are used to define type of variable means a variable hold which type of data (i.e char,interger,float e.t.c).
so there are 6 data types available in the C are.
1.) Integer.
2.) Char .
3.) Float.
4.) Double.
5.) void .
6.) Enum.

Integer

Integer datat ype are used to define integer type.

Int Variable name

Example.

int val;

Char

char defines characters.

Example. Char val;
val=INDIA;

Double

Double use for large floating point variables.

Example.

Double val;

val=250000;

Enumerated

A enum type is integer type that allows to give the name to certain values.

Example.

enum language { english, french, spanish = 4, german, chinese };

If value assigned to the variable then that value for that variable is used .if not then the value of last variable + 1 is the value of that variable.

If no value is assigned to the variable then default value is used from 0.

english-0

french-1

spanish=4

german=5

chinese=6

Void

Void means "containing nothing"

void has no values therefore we can't use it to declare variable type.It is basically use to define the type of function like.

void main()

That's means the function main returning nothing.

Modifiers

Modifiers define the amount of memory allocated to the variable.

The type of modifiers are .
short
long
signed
Unsigned
short int >= int >= long int
float >= double >= long double
That means the value assigned by the short int is less than or equal to int .Similar the value assigned by the int is equal or less than value assigned by the long int.
If you want to check manually the ranges of integer and float then try the below code .
#include <stdio.h>
#include <limits.h>

void main()
{
printf("Signed char minimum value: %d \n", SCHAR_MIN );
printf("Signed char maximum value: %d \n", SCHAR_MAX );
printf("Unsigned char minimum value: %d \n", 0 );
printf("Unsigned char maximum value: %d \n", UCHAR_MAX );
printf("Char minimum value: %d \n", CHAR_MIN );
printf("Char maximum value: %d \n", CHAR_MAX );
printf("Signed short minimum value: %d \n", SHRT_MIN );
printf("Signed short maximum value: %d \n", SHRT_MAX );
printf("Unsigned short minimum value: %d \n", 0 );
printf("Unsigned short maximum value: %d \n", USHRT_MAX );
printf("Signed int minimum value: %d \n", INT_MIN );
printf("Signed int maximum value: %d \n", INT_MAX );
printf("Unsigned int minimum value: %u \n", 0 );
printf("Unsigned int maximum value: %u \n", UINT_MAX );
printf("Signed long minimum value: %ld \n", LONG_MIN );
printf("Signed long maximum value: %ld \n", LONG_MAX );
printf("Unsigned long minimum value: %lu \n", 0 );
printf("Unsigned long maximum value: %lu \n", ULONG_MAX );
printf("Signed long long minimum value: %lld \n", LLONG_MIN );
printf("Signed long long maximum value: %lld \n", LLONG_MAX );
printf("Unsigned long long minimum value: %lu \n", 0 );
printf("Unsigned long long maximum value: %llu \n", ULLONG_MAX );

getch();

}


Output



That's it i will continue this tutorial in next section too.

    Other Recommended Posts

0 Responses to "C Programming Data Types : Part 1"

Leave a Reply