The C programming language was developed by Dennis Ritchie at
the Bell Laboratories in 1972. C evolved from two earlier languages called BPCL
and B which were developed at Bell laboratories. Because of its features, C
became popular very fast and by 1980s it was one of the most popular programming
language being used.
C is a general purpose structured programming language. It
has a rich set of data types and has a syntax that uses the English language
keywords. Its features categorize it as a high level language. C has additional
features that allow it to be used at the lower level, thus bridging the gap
between the machine language and the conventional high level languages. This
flexibility allows C to be widely used for systems programming.
C compilers are commonly available for computers of all
sizes. The compilers are usually compact, and they generate object codes that
are small and highly efficient as compared to programs compiled in other high
level languages.
An important characteristic of C is that the programs are
highly portable. This is because C implements most computer dependent functions
as its library functions.
Every version of C is accompanied by its own set of
library functions. The library functions are relatively standardized.
Therefore, most C programs can be processed on many different computers with
little or no alteration. Most commercial C compilers support the features of C
that are included in the ANSI standard.
BASIC
STRUCTURE OF A C PROGRAM
Documentation
Section
Link Section
Definition
Section
Global
Declaration Section
Main()
{
Declaration
Section
Executive
part
}
Subprogram
section
Function 1
Function 2
-
-
Function n
|
Documentation Section – This section consists of a set of
comment lines giving the name of the program and other details.
Link Section – This section provides instructions to the
compiler to link functions from the system library. C program depends upon some
header files for function definition that are used in the program. Each header
file has extension ‘.h’. The header files are included at the beginning of the
program in the C language. These files should be included using #include
directive as given below
Example:
#include
(This will find header file in standard directory)
Or
#include<stdio.h> (This will find header file in
Current and Standard directory)
Definition Section – This section defines all symbolic
constants.
Global Declaration Section – There are some variables and
those variables are declared in this section that is outside of all functions.
main() function – Every C program must have one main()
function section. int main(void) is the function definition for main().
Parenthesis followed to main is to tell the user again that main() is a
function. int main(void) function return an integer.
void main(void) – This function takes no arguments and
returns nothing. The program contains statements that are enclosed within the
braces. The opening braces “{“ and closing braces “}”. In these two braces
main() function two parts, declaration part and executable part. It is user
defined function. The opening braces sometimes called logical start and closing
braces known as logical end of the program.
Declaration Part declares all the variables used in the
executable part. There should be at least one statement in the executable part
which contains instructions to perform certain task. The declaration and
executable part must appear between the opening and closing braces. All
statements in the declaration part should end with the semicolon.
Subprogram Section – This section contains all the user
defined functions that are called in the main function.
Write a program to illustrate the use of comment
statement.
#include<stdio.h>
Void main()
{
/* Start of
Printing */
printf(“My
first C program.”);
/* End of
Printing */
}
Test run:
My first C program.
|
My first C program
on the screen. printf() is a predefined library
function in C.
|
C
is a middle level language i.e. has the capabilities of the low level languages
as well as the high level languages.
·
C
is a highly portable language. A C program written for one computer or
operating system can be run on another computer or operating system with little
or no modification.
·
C
is a highly structured language and C program are written as collection of
modules or functions.
·
C
has a well defined syntax or set of rules.
·
Execution
of a C program starts with the main() function.
·
C
is a case-sensitive language. It is case sensitive because it follows strict
rules even in an alphabetical case either lowercase or uppercase. For example,
typing Int instead of int result in compilation error. Because there is
uppercase I instead of lowercase i in the example.
·
Every
C statement is terminated by a semicolon (;).
·
Comment
statements are non executable statements.
No comments:
Post a Comment