What are Tokens, Variables in C programming language

Introduction

The C programming language and human languages are very similar in many aspects. Human languages consists of character sets which make up words and words are combined to form meaningful sentences. In English language character set is the set of alphabets.

Similarly, in C programming language characters are used to form tokens (words) which are then combined to make instruction.

C Character Set

C character set contains upper and lower case alphabets, digits and special symbols. Alphabets and digits together are called alphanumeric values.

C Tokens

The smallest meaningful unit in C programming language is called token. They are classified as below
  • C Tokens
    • Keywords
    • Constants
    • Identifiers
    • Operators

What are keywords in C ?

The words which are already defined in the C programming language are called keywords. They are also referred to as reserved words. A programmer cannot use the keywords in any way, other than specified syntax. They are always written in lowercase. There are 32 keywords in ANSI (American National Standards Institue) C programming language.

Here are the keywords used in ANSI C language

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

What are identifiers ?

An identifier is a user defined name given to elements in a C program.

Rules for using identifiers

  1. An identifier name must only contain alphabets and digits and must begin with an alphabet.
  2. No special symbols are allowed except underscore, it treated as alphabet.
  3. Keywords cannot be used as identifiers.
  4. C is case sensitive. C treats uppercase and lowercase characters differently.
  5. In most of the ANSI C compilers the first 31 characters are significant.

What is variable ?

A symbolic name assigned to a memory location to identify it uniquely is called a variable. A variable is an identifier. For more on variables refer to this tutorial on variables and data types in C.

Examples of variables: binary_num, number, num_123, emp, salary

What are constants in C ?

Fixed values that are directly used in C programs are called constants. they are classified as below
  1. Integer constants
  2. Character constants
  3. Floating point constants
  4. String literals
  5. Enumeration constants

What are operators in C ?

An operator is a symbol that represents an operation. An operator requires one or more values called operands to perform an operation. Operand instruct the compiler to perform some action.

Example of operand: * represents multiplication which requires two values means two operands.