C Programming - Data Types

C Programming - Data Types

Ø Data type in C language:
The basic element of any program, which describes the nature of variables is called data type .Data types are mainly used to define the type and nature of data such that compiler detects and proceeds.

Data types used in C are as follows:

1.     Int: - int is the keyword for integer. It contains the whole numbers between -32,768 to 32,767. It requires 2 bytes memory and its type specifier is %d.
Examples: - int a=10;
2.     Float: - float is the keyword for floating numbers i.e. decimal numbers. It contains number 3.4e – 38 to 3.4e+38. It requires 4 bytes memory and its type specifier is %f. Example: - float pi=3.14;
3.     Char: - char is the keyword for character. It represents the single alphabet. It requires 1 byte memory and its type specifier is %c. Example: - char choice;
4.     String: - The collection of character is called string. It is enclosed within double quote. Its type specifier is %s.
Example: Char str= “Computer”;