0% found this document useful (0 votes)
3 views

Chapter 2 Introduction to C.doc

Uploaded by

anfalsuriya7333
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Chapter 2 Introduction to C.doc

Uploaded by

anfalsuriya7333
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Chapter 2.

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.

Eg:- valid Identifiers:


Area, volume, tax, a1, a12, Sum_of_digit, _extvalve, etc.
● Constant:-
⮚ Constant is a value stored at memory location. This is value with one or more decimal
digits, either positive or negative where the decimal point is optional. This value is stored
in memory as constant value which cannot be altered.
⮚ C constants are into two categories.

Rules for constructing:-


1) A constant must have at least one digit.
2) It could be either positive or negative.
3) It must have a decimal point.
4) If no sign precedes an integer constants, it is assumed to be positive
5) No commas or blanks are allowed within integer constant.
6) The allowable range for short integer constant is -32,768 to +32,767.
7) E.g. 1263, -6712, 34, 2 etc.

Rules for constructing real Constant :-

1) A real constant must have at least one digit.


2) It must have a decimal point.
3) It could be either positive or negative.
4) Default sign is positive.
5) No commas or blank space are allowed within real constant.

E.g. 11.6, 3.1415, -12.1263 etc.

Rules for constructing character construct:-

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,

Rules for constructing variable:-

A variable name is any combination of alphabet, digits or underscore.


The first character in variable name must be alphabet.
The meaning of variable names in uppercase lowercase or mixed case is different.
E.g. “Amount” in different from “amount”.
No commas or blank are allowed within a variable name.
Reserved Keywords (32 words) are not permitted for variable name.
No special symbols other than an underscore can be used in variable name.

● 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’.

Auto Double If Statics

Break Else Integer Structure

Case ENUM Cong Switch

Char Extern Near Type def

Const Float Register Union

Continue Far Return Unsigned

Default For Short Void

Do Go to Signed while

You might also like