Elements of C Programming

As every language have some grammatical rules and basic elements. Before understanding programming it is must to know the basic elements of C language. These basic elements are character set, variables, datatypes, constants, keywords (reserved word), variable declaration, expressions, statements, etc. All these elements are used to construct a program in C language.

C CHARACTER SET
The characters that are used in programs are given below –
Alphabets
A,B,C,D,…………………..Z
a,b,c,d…………………….z
Digits
0,1,2,3,4,5,6,7,8,9
Special characters
Besides some special characters are also used which are given below –

Character
Meaning
Character
Meaning
+
plus sign
~
tilde
-
minus sign (hypen )
(
left parenthesis
*
astrick
)
right parenthesis
%
precent sign
{
left braces
/
forward slash
}
right braces
\
backward slash
[
left bracket
<
less than sign
]
right bracket
>
greater than sign
!
exclamation sign
#
hash sign
|
vertical bar
^
caret
$
dollar sign
&
ampersand
,
comma
single quote
.
period (dot)
double quote
:
colon
@
at the rate
?
question mark
;
semi colon

EXECUTION CHARACTER/ESCAPE SEQUENCE
Some characters such as new line, tab, backspace, etc cannot be printed on the screen thru keyboard like other normal characters. C supports the combination of (\) with the C character set to print these characters.
These character combinations are called escape sequence. These escape sequence are represented by two characters. The first character is “\” and the second character is from the C character set. Some escape sequences are as given below –

Escape sequence
Meaning
ASCII value
Result
\b
backspace
008
Move the cursor to the precious position of the current line
\a
bell (alert)
007
Produce a beep sound for alert
\r
carriage return
013
Move the cursor to the beginning of the current line
\n
new line
010
Move the cursor to the beginning of the next line
\f
form feed
012
Move the cursor to the initial position of the next logical page
\0
null
000
Null
\v
vertical tab
011
Move the cursor to the next vertical tab position
\t
horizontal tab
009
Move the cursor to the next horizontal tab position
\\
backslash
092
Present a character with backslash (\)

TRIGRAPH CAHRACTERS
There is a possibility that the keyboard doesn’t print some characters. C supports the facility of “trigraph sequence” to print these characters. This trigraph sequence is combination of three characters. First two are ??’ and third character is any character from C character set. Some trigraph sequence are as given below –

Trigraph sequence
Symbol
??<
{ left brace
??>
} right brace
??(
[ left bracket
??)
] right bracket
??!
| vertical bar
??/
\ backslash
??=
# hash sign
??-
~ tilde
??’
^ caret

RESERVED WORDS/KEYWORDS
Reserved words are the words whose meaning has already been explained to the C complier (or in a broad sense to the computer) for doing specific tasks. They are also called keywords. The keywords cannot be used as variables names because if we do so we are trying to assign a new meaning to the keyword, which is not allowed by the computer.
There are only 32 keywords available in C which are given below –

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

DELIMITERS
Delimiter is used for syntactic meaning in C. These are as given below –

:
colon used for label
;
semicolon end of statement
( )
parenthesis used in expression
[ ]
square bracket used for array
{ }
curly braces used for block of statements
#
hash preprocessor directive
,
comma variable delimiter