Wednesday, November 21, 2012

Module 2: Data Type, Constant, Variable (Tep Senghak)


Nama: Tep Senghak
Nim: 49012084
Major: d4 TMD ITB Batch 6

Module 2

Data Type, Constant, Variable

Data Type

Data type is a set of values together with a set of operations. C++ data types fall into the following three categories:
- Integral, which is a data type that deals with integers, or numbers without a  decimal part.
- Floating-point, which is a data type that deals with decimal numbers
- Enumeration, which is a user-defined data type.

Integral data types are further classified into the following nine categories:
- char
- short
- int
- long
- bool
- unsigned char
- unsigned short
- unsigned int
- unsigned long

Every data type has a different set of values associated with it. For example, 
char data type is used to represent integers between –128 and 127. The
int data type is used to represent integers between –2147483648 and 2147483647, and the short data type is used to represent integers between –32768 and 32767.

Floatin Data Type

C++ provides three data types to manipulate decimal numbers:
- float
- double
- long double

Float represent any real number between -3.4E+38 and 3.4E+38. The memory allocated for a value of the float data type is four bytes.Double represent any real numb-1.7E+308 and 1.7E+308. The memory allocated for a value of the double data type is eight bytes. The memory allocated for a value of the long double data type is fifteen bytes.

Variable

A variable is an identifier whose value can be changed according to the needs of the program. Each variable has a specific type, which determines the size and layout of the variable's memory. Example of variable:
- int i, j, k;
- char c, ch;
- float f, salary;



This video below show you examples about data type, constant, and variable in C++ programming language, which is developed with Microsoft Visual Studio 2010.



 You can also visit this video at www.youtube.com by click this link below.

2. http://www.youtube.com/watch?v=YrQ3Dp-6Jxg&feature=youtu.be






No comments:

Post a Comment