Note on C Programming Language

  • Note
  • Things to remember

THE HISTORY OFC

The C language was developed at Bell Laboratories (now AT& T’: American Telegraph & Telephone) in the early 1970’s by a system programmer named Dennis Ritchie. It was written originally for programming under an operating system called UNIX, which itself was later rewritten almost entirely in C.

Its name encrypted as C, derives from the fact that it is based on an earlier version written by Ken Thompson, another Bell Laboratories systems engineer. He adapted it from a language that was known by the initials BCPL (Basic Combined Programming Language). Thompson derived his programming language name as B, the first of the initials BCPL.

.

Source: www.thewildblogger.com

When the language was modified and improved to its present state, the second letter of BCPL, C was given to it. The C language is often described as a middle-level language. It permits programs to be written in much the same style as that of most of the high-level programming languages.

It also interacts with the inner workings of the computer. The American National Standards Institute has established certain standards for C, which are known as ANSI C in addition to the original version of C developed by Dennis Ritchie. Another popular version of C is Turbo C.

Merits of C Programming Language

In computer programming, different high-level programming languages are used. There are some programming languages specially designed to write programs for special kind of solutions such as simulations, games, space research, etc. Here are some merits of using C programming language.

  1. C is general purpose programming language. You can generate different kind of software such as billing system, games, utilities, word processor, etc.
  2. C is the structured programming language. It uses structured statements such as while, for, etc.
  3. C is a standardized programming language. For example ANSI (American National Standards Institute) C is a standard programming language.
  4. The C language can run in any computer system. It is system independent.
  5. It has the small range of data types of detailed data manipulation statements with power data definition methods.
  6. It is a language of few words such that the programmer can remember them easily.
  7. It is a highly efficient programming language since C compilers are generally able to translate source code into efficient machine instructions.

Structured programming

In 1965, a Dutch Professor E. W Dijkstra suggested the elimination of the GO TO statement. In 1966, a paper presented in Italian (and later translated into English by C. Bohm and G. Jacopini) defined the theoretical framework for structured programming. The paper stated that any program solution can be expressed in three fundamental control blocks: a processing box, a decision symbol of the IF… THEN… ELSE type and some form of looping procedure.

.

Source:www.gograph.com

These three components are the basis for structured programming solutions. The identification of these three structures, namely (a) used to follow a sequence of steps (b) select alternative paths and (c) establish program loops formulated the foundation of structured programming. Some advantages of structured programming are:

  1. Complex programs may be divided into simpler and more manageable elements.
  2. Simultaneous coding of modules by several programmers is possible.
  3. A library of modules may be created and these modules can be used in other programs.
  4. Reduced testing and debugging time
  5. Increased programmer productivity.
  6. Less complexity in programs that are essentially maintained and modified.
  7. Increased clarity by reducing complexity.

Features of C Programming Language

The C language was successful in developing UNIX operating systems. It has special reasons to become very popular in the programming world.

  • Portability: This refers to the ability of a program to run in different environments. Some programming language compilers such as FORTRAN and Pascal could be used in those computers containing the same compilers. Since, C languages have different compilers almost in all systems, a C is termed as the most portable language.
  • Flexibility: The C language combines the convenience and portable nature of high-level language with the flexible nature.
  • Wide acceptability: The C language is known to the entire world. The language is suitable for projects at the system level and at the application level.

Program Characteristics

Although many programs are written by many programmers, some common characteristics of program which makes it readable and portable are:

  1. The program should maintain its integrity. It should be accurate in calculations.
  2. The program should be clear in reading. It should be accurate in calculations and enhance the readability of the program for future reference.
  3. The program should be designed in a simple logic. Simple logic is easy to understand.
  4. It should be executed very fast and utilize the memory efficiently.
  5. The program should be broken down into pieces or modules. A modular program is easy to handle and read.
  6. The program should be general with reasonable limits.

Elements of C

Before we begin about different aspects of C programming language, let us discuss on some of the important elements of C. Every C program consists of one or more modules. These modules are called functions. One of the functions must be called main ().

The program will always begin by executing the main function. This function may access other functions. There can be many functions. Each function should be defined separately. The user defined functions are either defined ahead of the main function or within the main function. Each function must contain the following:

  1. A function heading, which consists of the function name (including the arguments if present)?
  2. A list of argument declarations if the arguments are included in the heading.
  3. A compound statement, which comprises the remainder of the function.

The arguments are also called the parameters. Each compound statement is enclosed within a pair of braces i.e. { }. The Comments or remarks may appear within the program anywhere within the delimits /* and */. The comments help to read the program and make convenient during debugging the program errors.

Example 1:

#include <stdio.h>

#include <conio.h>

Void main ()

{

Printf (“\n Hello Learner.\n”);

Printf (:\n Bye”);

Getch();

Explanation

#include directive: This is an essential directive. A directive is linked to a header file. The header file make full use of the I/O functions of the standard C library. Here, stdio.h is a header file and # sign is known as processing directive.

Void main() function: This is the main function that must appear in every C program. Main without void is used when where there are no arguments main() without any parameters has an argument.

Printf () function: The letter f in print function stands for formatted. This function is used to print out the messages, either on screen or paper.

{} braces surround the body of the function used to group statements together.

\n represents new line sequence or new line start. This is also known as the escape sequence and every line is terminated with a semicolon (;) in C programming language. Without \n, the characters are printed on the same line without any spaces.

Return 0 makes the compiler happy.

get () function holds from screen scrolling. It is defined in stdio.h header file.

C language users small letter or lowercase letters. No capital letters are used unless it is specified as in define statement.

The above program is rewritten to understand the function of void and return statements.

#include <stdio.h>

main ()

{

Printf (“\n Hello C”);

Printf (“\n Bye”);

Return 0;

}

In this case, the compiler is happy to execute the program. The above program is rewritten in a different way. It gives the same output as we did with previous programs.

References:

Khanal, R.C. Khanal, R.C. Computer Concept for XII. Pashupatigriha Marga, Thapathali, Kathmandu, Nepal: Ekta Books Distributors Pvt. Ltd., 2010. 131-134.

Adhikari, Deepak Kumar.,et.al., Computer Science XII,Asia Publication Pvt.Ltd

  1. C is the structured programming language. It uses structured statements such as while for, etc. C is a standardized programming language. The program should be designed in a simple logic. Simple logic is easy to understand.
  2. It should be executed very fast and utilize the memory efficiently. The program should be broken down into pieces or modules.
  3.  Every C program consists of one or more modules. These modules are called functions. One of the functions must be called main().
  4. Each function should be defined separately. The user defined functions are either defined ahead of the main function or within the main function.
.

Very Short Questions

0%

DISCUSSIONS ABOUT THIS NOTE

You must login to reply

Forum Time Replies Report
Vois

Meaning of void


You must login to reply

khagendra basnet

what is function call?


You must login to reply