Data type and storage

Data Type And Storage And Keywords

To store data inside the computer we need to first identify the type of data elements we need in our program. There are several different types of data, which may be represented differently within the computer memory. The data type specifies two things:

  1. Permissible range of values that it can store.
  2. Memory requirement to store a data type.

C language provides 4 basic data types viz., int, char, float and double. Using these, we can store data in simple ways as single elements or we can group them together and use different ways to store them as per requirement. The 4 basic data types are described in below table.

 

Data Type Type of Data Memory Range
char char 8 -127 to 128
unsigned char char 8 0 to 255
signed char char 8 -127 to 128
int int 16 or 32 -32767 to 32768
unsigned int int 16 or 32 0 to 65,535
signed int int 16 or 32 same as int
short int int 16 -32767 to 32768
unsigned short int int 16 0 to 65,535
signed short int int 16 same as short int
long int int 32 -2,147,483,647 to 2,147,483,647
long long int int 64 -(2*63-1) to 2*63 -1 (Added by C99)
signed long int int 32 same as long int
unsigned long int int 32 0 to 4,294,967,295
unsigned long long int int 64 2*64 -1 (Added by C99)
float float 32 1E-37 to 1E+37 with six digits of precision
double double 64 1E-37 to 1E+37 with six digits of precision
long double double 80 1E-37 to 1E+37 with six digits of precision

Identifiers

Identifiers are the names given to various program elements such as constant, variable, function names and arrays etc. Every element in the program has its own distinct name but one cannot select any name unless it conforms to valid name in C language. Let us study first the rules to define names or identifiers.

Rules for forming Identifiers

  1. Identifiers are defined according to the following rules:
  2. It consists of letters and digits.
  3. The first character must be an alphabet or underscore.
  4. Both upper and lower cases are allowed. Some text of different case is not equivalent, for Example:  TEXT is not the same as text.
  5. Except for the special character underscore(_), no other special symbols can be used.

For example, some valid identifiers are as

X
X123
_X123
temp
tax_rate

 

Keywords

Keywords are reserved words which have a standard, predefined meaning in C. They cannot be used as program-defined identifiers.

The lists of C keywords are as follows:

char int printf long
union continue goto while
if double enum const
for sizeof do else
struct register float signed
volatile typedef switch break
static auto case return
unsigned default void short

Note: Generally all keywords are in lower case although uppercase of same names can be used as identifiers.

Control characters (Escape sequences)

Certain non printing characters as well as the backslash () and the apostrophe(‘), can be expressed in terms of escape sequence.

  • \a – Bell
  • \n – New line
  • \r – Carriage return
  • \b – Backspace
  • \f – Formfeed
  • \t – Horizontal tab
  • \” – Quotation mark
  • \v – Vertical tab
  • \’ – Apostrophe
  • \\ – Backslash
  • \? – Question mark
  • \0 – Null

 

Related Post

Dart Introduction | Dart programming language Dart Introduction Dart is a scalable language that you can use to write simple scripts or full featured apps. Whether you’re creating a mobile app, w...
Dart Libraries | Dart Tutorial Dart Libraries Dart has the following libraries, which are included in all Dart platforms: dart:core This library is automatically imported into ev...
Strings String can be represented as a single-dimensional character type array. Strings in C are group of characters, digits, and symbols enclosed in quotatio...
Introduction To C A Brief History Of C   C was invented and first implemented by Dennis Ritchie on a DEC PDP-11 that used the Unix operating system. C is the r...
Create UITableView (Table View) By the use of stor... How to use UITableView in Above IOS 8 and Swift (UITableView) In this tutorial we are study how to use the TableView in Swift. One of the most common...
Continue Statement in JAVA Continue Statement in JAVA Suppose you are working with loops. Sometime it is desirable terminate the loop or skip some statement inside the loop wit...

Leave a Reply

Your email address will not be published. Required fields are marked *

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.