Fragments Of C,C++ & Java (For Successful Coding)

                                              Basic Terms in C...

1.Tokens

The smallest unit of  C program is known as tokens. The basic component of a source code or the Building pieces of a source code through which a program is completed to its achievement.

Example- variables, keywords,Identifiers,operators, Special Characters.
       
    I'll be defining each Token to make its importance and use clear.

2.Identifiers.

Identifiers as thee name suggest are used to identify a programs function, variables, arrays e.t.c created by you. These are the unique names you give to the member variables, member methods and other components of a C program.
           
 Naming rules for an Identifier:-
  • It should not start with a digit (0-9)
  • First character can be a Upper Case( Capital) Character or Lower Case(Small) Character.
  • C is Case Sensitive and hence Upper Case character and Lower Case Character is treated differently.  (AMAN and aman are treated diffrently in C).
  • Special characters are not allowed for naming a variable / identifier except Underscore(_).
  • Keywords cannot be used as Identifier.
Examples:- prince12 , Prince12 , Shubham_Prince ,

3.Keywords :

Keywords are the reserved words which C compilers already know and conveys special meaning to it. 
Whose meaning has already been explained to the compiler. That means at the time of designing a language, some words are reserved to do  specific tasks. Such words are called as keywords or reserved words. 
 C  support 32 keywords.


Example:- new, int, float, double, char, break,continue e.t.c. 

4.Constants :

They do have similar properties like Variables in C except that the values related to these variables do not change during the execution of a program.
They are also known as Literals.

TYPES OF CONSTANT
  • Integer constants        (1,2,3,90, any value except decimal value)
  • Real or Floating point constants             (14.8,40.7, any value with decimal)
  • Octal & Hexadecimal constants              (x0H4, 135 )
  • Character constants    ('a', 'b' , any single digit or character enclosed in single quotes) 
  • String constants("gu52" , any combination of characters and digit in double quotes)
  • Backslash character constants  (\t ,\b, : Escape Sequence Or Wild Characters)



We can define constants in a C program in the following ways.



By “const” keyword
By “#define” preprocessor directive


5.Operators:

Operator  is a symbol which performs particular operation. C supports a rich set of operators
Operators work on Operands. 

TYPES OF OPERATORS:-
  • Arithmetic operators 
  • Assignment operators
  • Relational operators
  • Logical operators
  • Bit wise operators
  • Conditional operators (ternary operators)
  • Increment/decrement operators
  • Special operators

Special characters:

All characters other than alphabets and digits  are treated as special characters.
Eg:   * , % , $ , {  ,etc.

..
Hope you'll be able to understand the following Tokens which is required to create a C program. 
It might not be an elaborated format but you can request me using my mail id.
Regards.


Smiling and don't forget to contact me for further assistance. Your Friendly Coder. SPrince

Comments

Popular posts from this blog

Introduction To Pointers

Keywords (Extension to Fragments Of C)