Wednesday, 24 August 2016

C++ DATA TYPES


1. int data types(basically for integers)

  Integers are represented with int data type.
  For example:    int num=7;
 This statement will create a variable of type int and assign it a value 7.

2. char data type(for characters)

   An identifier declared as char becomes a character variable.
  Example: char a;
  Letters,symbols etc are represented in memory by associated number codes which are integers only.   So it is often said to be an integer type.

3. float data types(for floating point numbers or numbers with decimal)

  A number having a fractional part is a floating-point number.
  For Example: 5.1245. It is a floating point number. Decimal point makes ensure that it is a floating     number. Let's say 30 is an integer, but 30.0 is a floating-point number.These numbers can also be    written in exponent notation. 349.4561 would be written as 3.494561E02.
 Example: float de=4.67;


4. double data type

  It takes twice as much memory as compared to floating point numbers. It also stores floating  numbers but with larger range and precision.

5. void data type

 void means empty. It is used as the return type when function don't have a return value.
Example: void func();

No comments:

Post a Comment