0% found this document useful (0 votes)
32 views8 pages

Unit1-History of C

Uploaded by

Sugnanarao M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views8 pages

Unit1-History of C

Uploaded by

Sugnanarao M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

1.

Introduction to C programming language:

History of C
C is a structured programming language. It is also known as function orientated programming
language. C programming language was developed in the year of 1972 by Dennis Ritchie at Bell
Laboratories in USA (AT & T).
In the year of 1968, research was started by Dennis Ritchie on programming languages like
BCPL, CPL. The main aim of his research was to develop a new language to create an OS called
UNIX. After four years of research, a new programming language was created with solutions for
drawbacks in languages like BCPL & CPL. In the year of 1972, the new language was
introduced with the name “Traditional C”.

The name 'c' was selected from the sequence of previous language ‘B’ (BCPL), because most of
the features of 'c' was derived from BCPL (B language).
The first outcome of the c language was UNIX operating system. The initial UNIX OS was
completely developed using 'c' programming language.
The founder of the ‘C’ language,Dennis Ritchie is known as “Father of C”and also “Father of
UNIX”.
C programming language is a very popular programming language, because it is reliable, simple
and easy to use and it is the base for almost all the other programming languages.

The following are the language before ‘c’ & various versions of ‘c’.

1. CPL (Common Programming Language)


The CPL was invented by Martin Richards at the University of Cambridge in the early of
1960's.

2. BCPL (Basic Combined Programming Language)


The BCPL was invented by Martin Richards at the University of Cambridge in the year of
1966. It was a popular programming language at that time. BCPL allows the user, direct access
to the computer memory. BCPL is the extension of CPL.

3. B Language
B language is derived from BCPL. It was introduced in the year of 1969 by Ken Thompson and
Dennis Ritchie at Bell Laboratory, USA. The B language is similar to the BCPL.

4. C Language
C language is derived from B language. It was introduced in the year of 1972 by Dennis Ritchie
at Bell Laboratory, USA. The C language was mainly developed to create a operating system
called UNIX. The name C is given based on the previous language B and BCPL.

5. ANSI C (C89)
In the year of 1983, the ANSI (American National Standards Institute) formed a committee to
frame standard specifications for the C language. In the year of 1989, this committee introduced
a standard version of C with the name "ANSI C" with standard library files. The ANSI C is also
called as C89 in short form.

6. C90
In the year of 1990, the ANSI C was got ISO (Intenational Organization for Standardization)
standardization with the inclusion of few new features like new library files, new processor
commands.

7. C99
In the year of 1995, many new features were added to the C90 to create a new version of it.
Basic structure of C programs:

C is a structured programming language. Every c program and its statements must be in a


particular structure. Every c program has the following general structure...

Line 1: Comments - They are ignored by the compiler


This section is used to provide small description of the program. The comment lines are simply
ignored by the compiler, which means they are not executed. In C, there are two types of
comments.
1.Single Line Comments: Single line comment begins with // symbol. We can write any
number of single line comments.
2.Multiple Lines Comments: Multiple lines comment begins with /* symbol and ends
with */. We can write any number of multiple lines comments in a program.
In a C program, the comment lines are optional. Based on the requirement, we write the
comments. All the comment lines in a C program just provide the guidelines to understand the
program and its code.

Line 2: Pre-processing Commands


Pre-processing commands are used to include header files and to define constants. We use
#include statement to include header file into our program. We use #define statement to define a
constant. The pre-processing statements are used according to the requirement. If we don't need
any header file, then no need to write #include statement. If we don't need any constant, then no
need to write #define statement.

Line 3: Global Declaration


Global declaration is used to define the global variables, which are common for all the functions
after its declaration. We also use the global declaration to declare functions. This global
declaration is used based on the requirement.

Line 4: intmain()
Every C program must write this statement. This statement (main) specifies the starting point of
the C program execution. Here, main is a user defined method which tells the compiler that this
is the starting point of the program execution. Here, intis a data type of a value that is going to
return to the Operating System after completing the main method execution. If we don't want to
return any value, we can use it as void.

Line 5: Open Brace ({ )


The open brace indicates the beginning of the block which belongs to the main method. In C
program, every block begins with '{' symbol.

Line 6: Local Declaration


In this section, we declare the variables and functions that are local to the function or block in
which they are declared. The variables which are declared in this section are valid only within
the function or block in which they are declared.

Line 7: Executable statements


In this section, we write the statements which perform tasks like reading data, displaying result,
calculations etc., all the statements in this section are written according to the requirement.

Line 9: Closing Brace ( } )


The close brace indicates the end of the block which belongs to the main method. In C program
every block ends with '}' symbol.

Line 10, 11, 12, ...: User defined function()


This is the place where we implement the user defined functions. The user defined function
implementation can also be performed before the main method. In this case, the user defined
function need not to be declared. Directly it can be implemented, but it must be before the main
method. In a program, we can define as many user defined functions as we want. Every user
defined function needs a function call to execute its statements.es for any C program
1.Every executable statement must end with semicolon symbol (;).
2.Every C program must contain exactly one main method (Starting point of the program
execution).
3.All the system defined words (keywords) must be used in lowercase letters.
4.Keywords cannot be used as user defined names(identifiers).
5.For every open brace ({), there must be respective closing brace (}).
6.Every variable must be declared before it is used.

C tokens:

Every C program is a collection of instructions and every instruction is a collection of some


individual units. Every smallest individual unit of a c program is called token.

In a c program tokens may contain the following


1.Keywords
2.Identifiers
3.Operators
4.Special Symbols
5.Constants
6.Strings
7.Data values

In a C program, collection of all the keywords, identifiers, operators, special symbols, constants,
strings and data values are called as tokens.
Consider the following C program...
#include>stdio.h>
int main()
{
int i;
printf(“ASCII characters”);
for(i=-128;i<=127;i++)
printf(“%d->%c”,i,i);
}
In the above program there are 22 tokens.

Keywords:
In C programming language, keywords are special words with predefined meaning. Keywords
are also known as reserved words in C programming language.
In C programming language, there are 32 keywords. All the 32 keywords have their own
meaning which is already known to the compiler.

Keywords are the reserved words with predefined meaning which already known to the
compiler
Whenever C compiler comes across a keyword, automatically it understands its meaning.

Properties of Keywords
1.All the keywords in C programming language are defined as lowercase letters so they
must be use only in lowercase letters
2.Every keyword has a specific meaning; users can not change that meaning.
3.Keywords cannot be used as user defined names like variable, functions, arrays,
pointers etc...
4.Every keyword in C programming language represents something or specifies some
kind of action to be performed by the compiler.
The following table specifies all the 32 keywords with their meaning...

Identifiers:

Identifier is a user defined name of an entity to identify it uniquely during the program
execution

Example
int marks;
char studentName[30];
Here, marks and studentName are identifiers.

Rules for Creating Identifiers


1.An identifier can contain letters (UPPERCASE and lowercase), numeric &
underscore symbol only.
2.An identifier should not start with numerical value. It can start with a letter or an
underscore.
3.We should not use any special symbols in between the identifier even whitespace.
However, the only underscore symbol is allowed.
4.Keywords should not be used as identifiers.
5.There is no limit for length of an identifier. However, compiler considers first 31
characters only.
6.An identifier must be unique in its scope.
Constants:
A constant can be defined as follows...

A constant is a named memory location which holds only one value throughout the program
execution.
In C programming language, constant can be of any data type like integer, floating point,
character, string and double etc.

Integer constants
An integer constant can be a decimal integer or octal integer or hexa decimal integer. A decimal
integer value is specified as direct integer value whereas octal integer value is prefixed with 'o'
and hexa decimal value is prefixed with 'OX'.
An integer constant can also be unsigned type of integer constant or long type of integer
constant. Unsigned integer constant value is suffixed with 'u' and long integer constant value is
suffixed with 'l' whereas unsigned long integer constant value is suffixed with 'ul'.

Examples
125 -----> Decimal Integer Constant
O76 -----> Octal Integer Constant
OX3A ----->Hexa Decimal Integer Constant
50u -----> Unsigned Integer Constant
30l -----> Long Integer Constant
100ul -----> Unsigned Long Integer Constant

Floating Point constants


A floating point constant must contain both integer and decimal parts. Some times it may also
contain exponent part. When a floating point constant is represented in exponent form, the value
must be suffixed with 'e' or 'E'.

Example
The floating point value 3.14 is represented as 3E-14 in exponent form.

Character Constants
A character constant is a symbol enclosed in single quotation. A character constant has a
maximum length of one character.

Example
'A'
'2'
'+'
In C programming language, there are some predefined character constants called escape
sequences. Every escape sequence has its own special functionality and every escape sequence is
prefixed with '\' symbol. These escape sequences are used in output function called 'printf()'.

Strings:

String Constants
A string constant is a collection of characters, digits, special symbols and escape sequences that
are enclosed in double quotations.
Ex: "This""is""btechsmartclass"

Special Symbols:

The following special symbols are used in C having some special meaning and thus, cannot be
used for some other purpose.

[] () {} , ; : * … = #

Braces {}: These opening and ending curly braces marks the start and end of a block of code
containing more than one executable statement.

Parentheses (): These special symbols are used to indicate function calls and function parameters.

Brackets []: Opening and closing brackets are used as array element reference. These indicate
single and multidimensional subscripts.

Variables :

Variable is a name given to a memory location where we can store defferent values of same
datatype during the program execution.
Every variable in c programming language must be declared in the declaration section before it is
used. Every variable must have a datatype that determines the range and type of values to be
stored and size of the memory to be allocated.
A variable name may contain letters, digits and underscore symbol. The following are the rules
to specify a variable name...
1.Variable name should not start with digit.
2.Keywords should not be used as variable names.
3.Variable name should not contain any special symbols except underscore(_).
4.Variable name can be of any length but compiler considers only the first 31 characters
of the variable name.

Declaration of Variable
Declaration of a variable tells to the compiler to allocate required amount of memory with
specified variable name and allows only specified datatype values into that memory location.

Declaration Syntax:

datatypevariableName;

Example: int number;


The above declaration tells to the compiler that allocates 2 bytes of memory with the
name number and allows only integer values into that memory location.

You might also like