Monday, January 20, 2014

Examples for Datatypes


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Example for Primitive Datatypes in C  
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

                       intvar.c

/* example for integer variable declaration */
# include <stdio.h>

main()
{
  int num = 100;
  printf("\nValue of num is %d", num);
  getch();
}

In this program,
we have declared a integer variable using the keyword 'int' . int is a primitive datatype
/* */ is a comment line and ignored by the compiler. Comment
lines are used for documenting the program which makes it more readable
* variables are declared in the beginning of the program
* the number of bytes allocated for a int variable is 2 bytes (32 bits) and it varies from compiler to compiler if the OS environment is different like Unix
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment