Friday, August 14, 2009

Data Type, Variables and Constant

Data Type
The are four basic data type for C namely:
  • char (character)
  • int (integer)
  • float (floating-point number)
  • void
Variables

Variables are named memory locations that have a type.

Must declare and define in order to used it.

Example

          int a;
          float b;
          char c;

Can not declare a variable of type void!!!
Can initialize a value to it during the declarations refers as initialization.

Example

          int a = 1;
          float b = 1.0;
          char c = 'a';

Constant

Data values that cannot b changed during the execution of the program.
Character constants are enclosed between two single quotes.
Example:
          'a'
          '\n'
String constant is a sequence of zero or more characters enclosed in double quotes
Examples:
          "a"
          "ums"

No comments: