Chapter 2 Introduction to C.doc
Chapter 2 Introduction to C.doc
Introduction to C
⮚ This strange sounding language is one of the most popular computer languages today,
because it is structured high level machine independent language. It allows software
developers to develop programs without worrying about the hardware platform where
they will be implemented.
⮚ C is a programming language developed at AT & T’S bell laboratories of USA in 1972 by
Dennis Ritchie. C was evolved from ALGOL, BCPL and B. C uses many concepts from
these languages and added the concept of data types and other power full feature.
⮚ C is popular structured programming language. It general purpose programming language
with many power full features such as pointer.
⮚ Because of its portability, it is used for developing software in many applications. It is
especially suitable for system programming. C is so popular because it is reliable, simple
and easy to use.
⮚ C programming language stands in between problem oriented language and machine
oriented language, which is why it is often called a Middle level language. Since it was
Design to have both: a relatively good programming efficiency (as compared to Machine
oriented language) and relatively good machine efficiency (as compared to problem
oriented language).
The history and development of C can be well illustrates by using following figure.
Feature of C
1) Alphabet:
A,B,C,D-------Y,Z
A,b,c,d--------y,z.
2) Digit:
0,1,2,3,4,5,6,7,8,9.
3) Special Symbol:
, comma < opening angle bracket
. period > closing angle bracket
; Semicolon _ under score
: colon $ dollar sign
# number sign ^Create
‘ Apostrophe *asterisk
” Quotation mark --minus sign
! exclamation mark + plus sign
/ vertical bar ( left parenthesis
~ tilde ) right parenthesis
% percent sign [ left bracket
? Question mark ] Right bracket
& Ampersand /slash
{ left Brace \ Back slash
} Right brace
1) It is robust language :- The rich set of built-in function and operator can used to write any
complex programs. It is well suited for both system software and business packages.
2) Programs written in C are efficient and fast due to its variety of data types and power full
operations.
3) There are only 32 keyword and its strength lies in its built in function, which can be used for
developing programs.
4) C is portable language, i.e., Program written for one computer can be run on another with little
or no modification.
5) C is well suited for structured programming, thus requiring the users to think of problem in
terms of function modules or blocks.
6) C has ability to extend itself. A C program is collection of functions that is supported by C
library. We can also add our own function to C library.
Character Set :-
Definition:- A character denotes any alphabet, digit or special symbol used to represent
information.
o C Support total 91 character including alphabets .digit and special symbols. Other than
this some white space are also used that is blank space horizontal tab ,carriage return
,new line etc,
● Identifier in C
An identifier is symbolic name used to refer to an entity such as a data type, constant, variable,
function, Array etc.
It is a plain sequence of alphabet and/or digit which compulsorily starts with an alphabet. No
punctuation, blank space or sign are allowed to use in an identifier. There is no limit on the length
of an identifier in C, but which may be in the Compiler. The language permits the use of special
symbol ( _ ), it is also possible that name can start with an underscore.
1) A character constant is either an single alphabet, a single digit, or special symbol enclosed
within single inverted commas. Both the inverted commas should point to the left.
2) The maximum length of a character constant can be 1 character.
E.g. valid constant – ‘A’, ’1’, ’5’, ’+’
Invalid constant –‘abc’ , ‘21’.
● Variable :-
⮚ Variable is stored at memory location. This is the value that may change during the
execution of program. This value stored in a memory location as variable value, which
can be accessed by variable name.
⮚ Variable names are names given to locations in memory of computer where different
constants are stored. These locations can contain integer, real or character constants.
⮚ The type of variable that it can support depends on the type of constants that it can
handle.
⮚ There are also different types of ‘c’ variable. These variable can also be classified as,
● Key words:-
Keywords are predefined by the language. Keywords are the words whose meaning has already
been explained to the compiler. The Keywords cannot be used as variable name because it will
assign a new meaning to the keyword, which is not allowed by the computer
The keywords are also called ‘Reversed words’. There are only 32 keywords available in ‘C’.
Following is the list of keyword in ‘C’.
Do Go to Signed while