C – Basic Key Terms of C Programming

Basic Key Terms of C Programming

C – Character Set

C uses the uppercase letters A to Z the lowercase letters a to z, the digit 0 to 9, and some special characters to form basic program elements

(e.g. Contents, Variables, Operators, Expression) as we discussed above. The special characters are listed below.

  1. Alphabets – Upper-Case (A,B,…….W,X,Y,Z).
  2. Lower-Case – (a,b,……w,x,y,z).
  3. Digits-(0, 1,2 …………8,9).
  4. Special Symbols : + – * / = ( ) [ ] { } ? : ; , . > < & * (^ % # | _ ~ ” ‘ !
  5. White space characters: Blank, Newline, Tab etc. (t, n, etc).

C – Tokens

Compiler collects the valid character-sets to make sensible tokens. So, it can be said that tokens are the collection of different characters, symbols, operators or punctuators.

The first job of the compiler is to test the validity of these tokens. There are six types of tokens as prescribed by C:

  • Keywords
  • Identifiers
  • Constant
  • String Constants
  • Operators and Punctuators

The token can be the combination of the predefined word know as keywords and combination of identifiers, constant eg. define pi 3.15., string constant and operators and punctuators etc.

C – Keywords

The reserved words that have standard predefined meaning in C are called keywords. The keyword can not be used as a variable name, array name or any other name.

They are used by the compiler as an aid to compiling the program. They are always written in lower case. There are 32 keywords in C programming language.

Auto Double If Static Break Else Int Struct Case   Enum
Long Switch Char Extern Near Typedef Cosnt Float   Register  Union
Continue Far Return Unsigned Default For Short
Void
Do Goto
Signed While                  

C – Identifiers

Identifiers are the programmer defined elements like the name of variables, functions arrays, structures etc, They are the fundamental requirement of any language.

These are token which are composed of sequence of letters, digits, and underscore ( _ ). Every language has its own rules for naming identifiers.

Identifiers are used to give unique names to different objects in the program. Rules For Naming Identifiers In C

  • An identifier is any combination of alphabets, digits or underscore. 
  • The first character in the identifier name must be an alphabet and not a digit but after that any digit may follow. 
  • No blank (white space) are allowed within an identifier. 
  • No special symbols other than underscore(as in stn_name) can be used in an identifier. 
  • Maximum length of identifier is compiler dependent. Originally it was 8 characters. ANSI C permits 31 characters in an identifiers. 
  • Upper case and lower case letters are distinct. 
  • A keyword cannot be used as an identifier. 
  • Identifier name should be unique. 
  • Same Identifier cannot be used again to give name to other object.
  • C Identifier Example

Following are some possible examples of identifiers to represent length of box;

LengthOfBox
Lenght_of_box
length2
LenGth
lb
l

C – Comments 

Comments are remarks or arbitrary text written by a programmer into programming codes, which are placed between the character sets /* and */. It is added by the programmer for documentation purpose.  

Comments are not tokens, so the compiler converts each comment into a single blank character. Thus, it becomes a non-executable part of the program.

It is ignored by the compiler and the programmer is free to write their comments within those symbols. Following are some examples of writing comments in C:

/* this is comment for c programming */
/*** test comment in c ***/
/* this is multiline
comment in
c  */

C – Code

/* A program to print hello world*/
--- Comment about program. 
#include<stdio.h>/*Header files- or preprocessor*/
int main(void)/* main finction*/ 
{/* statement start with curly braces*/    
printf("Hello,world"); /* it is end with semicolon signs ;*/    
return 0;} 
/* statement closed with curly braces*/