Skip to main content


Character set, variables, constants and keywords

Character set:
Character set contains alphabets, numbers, and symbols for representing information. Following set shows characters used in C:

Alphabets


A,B,C,D……………X,Y,Z
A,b,c,d…………….x,y,z
Numbers

0,1,2,3,4,5,6,7,8,9
Special Symbols

?></.,;’:”[]{}\|*-+_()*&^%$#@!

Variables:
Variable is an entity which can change or it is a name of the memory location. It should start with only alphabets or underscore. Also called identifiers.
e.g.  int A=10;
consider memory location 1000 in a computer’s memory where 10 value is stored. So we can retrieve or modify value 10 through variable A.
       
Constants:
Constant is an entity which cannot change.
e.g. int A=10; 10 is a constant.

Types of constants:
1.Primary Constants
2.Secondary Constants

Constants

Range
Integer

-32768 to +32767
Float

-3.4e38 to +3.4e38
Character

-128 to 127

Integer constant:
e.g int A=10, B=32768;
In given example, B has value out of range of integer constant so
Float constant:
e.g float f=2.3e+20;
2.3e+20=2.3*1020

Character constant:
Character constant consist only single alphabet, number or special symbol enclosed in a single inverted comma.
e.g. char A=’3’; 

Keywords:
Keywords are reserved words whose meaning is known to the compiler. Keywords should be in lower case. There are 32 keywords in C language:

 void

 return
 int
 case
 double

 public
 char
 long
 goto

 for
 while
 static
 unsigned

 switch
break
 union
 auto

 volatile
 struct
 continue
 sizeof

 if
 else
 const
 float

 short
 signed
 default
 typedef

 enum
 extern
 do



Comments

  1. Replies
    1. enum is especially used for storing fixed constants. e.g. months of year or days of week

      Delete
  2. what are the terminator used in c?

    ReplyDelete
    Replies
    1. We are using semicolon(;) for terminate all statements in C. If considering string i.e. array of character, it is terminated by '\0'. Also array can be terminated by '\0' if you wish but it is not recommended. Important fact is '\0' and 0 is same i.e. ASCII value of '\0' is 0.

      Delete

Post a Comment