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

C Intro

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

C Intro

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

C

Introduction

 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 the 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' were derived from
BCPL (B language).

The first outcome of the c language was the


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”.

The c programming language is very popular


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
1960s.
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
BCPL.
4. C Language
C language is derived from the 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 an
operating system called UNIX. The name C is
given based on the previous language B and
BCPL. Ninety percent of the UNIX operating
system code is written in C language. During
the 1970s, the C language became a very
popular programming language. Many
universities and organizations began creating
their version of C language for their respective
projects. So, C language has got many variants
at that time. Later it was standardized.
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
(International Organization for
Standardization) standardization with the
inclusion of a few new features like new
library files, new processor commands. And it
was also added with keywords const, volatile
and signed, etc... ISO standardized ANSI C as
ISO/IEC 9899:1990. This version is called as
C90 in short form.
7. C99
In the year of 1995, many new features were
added to the C90 to create a new version of it.
This new version of C was got ISO
standardization in the year of 1999 with the
name ISO/IEC 9899:1999. In the short form, it
is called as C99. Later C99 became the official
standard version of C.
General rules for any C program
1. Every executable statement must end
with a 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 can not 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 Program Basics
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 a small
description of the program. The comment lines
are simply ignored by the compiler, that 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
comments. All the comment lines in a C
program just provide the guidelines to
understand the program and its code.
Line 2: Preprocessing Commands
Preprocessing commands are used to include
header files and to define constants. We use
the #include statement to include the header
file into our program. We use
a #define statement to define a constant. The
preprocessing statements are used according to
the requirements. 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 a #define statement.
Line 3: Global Declaration
The 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: int main()
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, int is 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 a '{' 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 the
result, calculations, etc., All the statements in
this section are written according to the
requirements.
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 a '}' 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 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.

C Tokens
In a C program, a collection of all the
keywords, identifiers, operators, special
symbols, constants, strings, and data values
are called tokens.
Tokens are used to construct c programs and
they are said to the basic building blocks of a c
program.
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
8. C Keywords

As every language has words to construct


statements, C programming also has words
with a specific meaning which are used to
construct c program instructions. In the C
programming language, keywords are special
words with predefined meaning. Keywords are
also known as reserved words in C
programming language.

In the C programming language, there are 32


keywords. All the 32 keywords have their
meaning which is already known to the
compiler.
Keywords are the reserved words with
predefined meaning which already known
to the compiler
Properties of Keywords
1. All the keywords in C programming
language are defined as lowercase letters
so they must be used only in lowercase
letters
2. Every keyword has a specific meaning,
users can not change that meaning.
3. Keywords can not 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...

You might also like