Elements of C:


C character set

In order to develop its language the following characters are used, they are

  • Alphabets-It consists of uppercase letters A...Z and lower case letters a...z.
  • Digits- 0,1,2…9
  • Special characters- ,  Comma , & Ampersand , . Dot , ^Caret ,;   Semicolon , *  Asterisk, : Colon , > Greater than sign , !  Exclamation Mark , ( Opening Parenthesis , |  Pipe Line , )  Closing Parenthesis , / Slash , -  Minus Sign, ?  Question Mark , + Plus Sign , ' Single Quotation , <  Less than sign , " Double Quotation , [ Left Bracket , \ Backslash , ]   Right Bracket , ~   Tilde, { Open Brace , _ Underline.


The smallest individual units of the program are tokens. There are six types of tokens. They are Keywords, identifiers, constants, strings, operators and special symbols.


Keywords have a standard predefined meaning and they should be used only for their intended purpose. The keywords should be written in lower case.

Auto             double             int                   struct

Break            else               long                  switch

Case             enum               register              typedef

Char             extern             return                union

Const            float              short                 unsigned

continue         for                signed                void

default          goto               sizeof                volatile

Do               if                 static                while


These are the names given to the variables, functions, arrays and other user defined object. Identifiers are user defined names.


  •  Identifiers may be alphabets, digits and special characters with underscore.
  •  The first character must be alphabet
  •  No special characters are allowed.




The quantity whose value does not change during the program execution is called as constants. There are three types of constants.

  1. Numeric constants
  2. Character constants
  3. String constants


1.Numeric constants

It is made up of digits and some special characters. They are divided into integer and floating point.

Integer- It is made up of digits without a decimal point. The value ranges from -32,708 to +32,627.

Integer constant          Range

Long integer         2,147,483,648 to 2,147,483,647

Short integer         -128 to 127

Unsigned integer         0 to 65,535

Real constant-A number with one decimal point is called real constant. The real constant can be expressed in one of the two forms

  •  Fractional form- a number with one decimal point eg-0.52
  •  Exponent form- It is used to represent very large and very small real constants.eg-0.251E-5

Character constants

There are two types of character constant

  1. Direct
  2. Escape sequence



A single character is enclosed within single quotation marks. Eg-‘A’

Escape sequence

More than one character begins with a single quotation mark. The first character must be (/).

Character for Bell (Alert) '\a'. Character for Backspace '\b'.

Character for Horizontal Tab '\t'. Character for Vertical Tab '\v'.

Character for Newline (Line Feed) '\n'. Character for Form Feed '\f'.

Character for Carriage Return '\r'. Character for Quotation Mark '\"'.

Character for Apostrophe '\''. Character for Question Mark '\?'.

Character for Backslash '\\'. Character for Null '\0'.

Character for Bell (Alert) '\a'. Character for Backspace '\b'.

Character for Horizontal Tab '\t'. Character for Vertical Tab '\v'.

String constant

A sequence of characters enclosed in double quotes. It can be digits, alphabets, special characters.





A variable is a name given to the memory location to store data. A variable is a quantity whose value changes during the execution of the program.


  •  A variable is formed with alphabets, digits and special character.
  •  The first character must be alphabet.
  •  No special characters are included
  •  Variable used should be reserved word.



Types of variables:

  • Integer
  • Long integer
  • Short integer
  • Unsigned integer
  • Floating pint
  • Double
  • Character
  • Signed character
  • Unsigned character
  • String


Data types

The basic data types used in C are

Keyword         No.of bytes                               Range

char          1 byte                           -128 to 127

int          2 byte                   -32768 to +32767

float          4 byte               3.4 e-38 to 3.4 e+38

double 8 byte            1.7 e-308 to 1.7 +308


An operator is a symbol that represents some operation which can be performed on data. The various types of operators are

  • Arithmetic operator

Operator               Name                      Example                       Description

a + b                 Addition               X=3 + 5                    Adds the two operands

a - b                  Subtraction           X=3 - 5                    Subtracts the second operand from the first Operand.

a * b                  Multiplication         X=3  * 5                  Multiply both the operands.

a / b                   Division                X=15 /3                   Divides the first operand by the second.

a % b                  Modulo Division      X=3 % 2                  Returns the remainder after

  • Relational operators

These are used to find out the relationship between two operands

Operator             Operation                                    Example

>                      Grater than                               A>B

<                      Less than                                 A

>=                     Greater than equal to                A>=B

<=                     Less than equal to                    A<=B

==                     Equal to                                  A==B

!=                      Not equal to                            A!=B

  • Logical operators

Logical operators are used to find out the relationship between two or more relationship expressions.

Operator Meaning

&&              AND

||               OR

!                 NOT

Increment and decrement operators

There are two special operators in C to control the loops in an effective manner. They are increment and decrement operator.

  1.  Increment operator – It is used to add 1 to the value contained in the variable. Eg- a++ which means a=a+1
  2.  Decrement operator- It is used to subtract 1 from the value contained in the variable. Eg- a—which means a=a-1


Conditional Operator

It is used to build some conditional expression. It has three operators hence it is called ternary operator.




a>b is tested first and if it is true big=a else big=b

Assignment operator

It is used to assign values to variables. The assignment operator is used.

Variable =constant



Bitwise operator

The bit by bit operation is performed.

Operator                           Meaning

&                                 Bitwise AND

|                                  Bitwise OR

^                                 Bitwise exclusive OR

>>                                Bitwise right shift

<<                                Bitwise left shift

~                                 Bitwise complement

Sizeof operator

This operator is used to find the number of bytes occupied by the operand. The general form is

Variable=sizeof (operand);

Type casting:

It is the process of converting one data type into another.The two types of conversion are

1. Explicit conversion

The process of converting one data type into another explicitly using the cast operator.

newtype(variable or expression);

2. Implicit conversion

The operands with lower data type operands are automatically converted into higher data types. This type of conversion is called implicit conversion.

Variable declaration:

The variables must be declared before we use it. Using the declaration we can declare the variables. The general form is

data-type variable list;


int a,b,c;

Initializing variables

The process of assigning initial values to the variables is called initializing variables. The variables can be initialized at the time of declaration. The general form is

data-type variable =value;


int a=100;

Formatted and unformatted output functions

Input-output functions are used to transfer information between the computer and the input-output device. The input and output functions are carried out using the input-output function calls.

Formatted input function:


It is used to give data to the variables using the keyboard. The general form is

Scanf(“control string’,&variable1, &variable2 ....& variablen)

&- ampersand symbol before each variable is called as address operator.



Formatted output function


It is used to output the results of the program to the user. The general form is

printf(“control string”,list);



Elements of C Language Assignment Help