Pages

Wednesday, July 13, 2011

Data Type With C/C++ Language

Playing with data is the main task of a C and C++ programmer. C/C++ divides computer data into various categories such as, integer number (1, 2, 5, 7…), floating number (2.5, 3.5, 8.9…), various character (a…z, A…Z, #, &) etc. The following table will describe the data types used in C and C++ program.


Data Type
Example
Description
char
‘S’ or  ‘J’
Various characters
int
325759
Integer value
float
3.1416
Floating number
double
8.430896314
Floating number greater than float.


These four data types are the basic built-in data types in C/C++ programming. C/C++ keeps data into system memory while running program and different data types allocate different memory size. Data types and memory allocation list is given below.


Data Type
Memory  Space
Range
char
1 byte or 8 bit
Any number between -128 to 127 but it is used only to keep ASCII character.
integer
2 byte or 16 bit
Any number between -32768 to 32767
float
4 byte or 32 bit
Any number between
double
8 byte or 64 bit
Any number between



Example of different data type in C and C++ program

#include<stdio.h>
#include<conio.h>
void main()
{
 clrscr();
 printf("char   takes %d byte\n",sizeof(char));
 printf("int    takes %d byte\n",sizeof(int));
 printf("float  takes %d byte \n",sizeof(float));
 printf("Double takes %d byte",sizeof(double));
 getch();
}

Program Output



1 comment:

Anonymous said...

сосновый бор ленинградская область знакомства

в [url=http://goooogl]Gooogle[/url] частное интимное женское фото
лучшие интимные салоны юго востока москвы