Overview, History, Features, Advantages and Disadvantages of C language

 

4.1 Introduction

Overview, History, Features, Advantages and Disadvantages of C language

Overview of C Language

The C language is one of the most powerful languages. In the beginning due to the different architectures available, the programmer had to learn different languages to create different types of applications. The problem with low level languages is that they are very difficult for humans to understand and develop. On the other hand, High Level Languages are easy for humans to understand.

 

The C language is a highly efficient programming language and easy to understand. It has both the properties of high level language and low level language, so it is also termed as Middle Level Language or intermediate language between high level language and low level language. It is a very powerful programming language because it is used to prepare system software as well as application software. It is a kind of general purpose, structured programming language. It has large numbers of vocabularies and simple syntax to write a program.

 

History of C Language

C is a general purpose programming language. C language was designed and developed by Dennis Ritchie at Bell Laboratories in 1972. It is an offspring of the "Basic combined programming language" called BCPL developed in the year 1967 at Massachusetts Institute of Technology. This language is associated with the UNIX operating system. The source code for the UNIX operating system is coded in C. It runs under a number of operating systems including MS DOS. C programs are efficient, fast and highly portable programming language. The C language is named as C because its precedence was called B which was derived from BCPL by Ken Thompson in 1970 in Bell Labs. The development of UNIX in the C language made it uniquely portable and improvable.

POINTS TO REMEMBER

 

C is a general purpose, portable, compact, simple and flexible programming language.

Features of C Language

C Language is a very popular language because it has large numbers of features for programmers to write medium types of programs. Some basic features of C language are given below.

       It is highly portable Language

       It is a structured programming language because the program is divided into a number of functions.

       It is a general purpose high level programming language.

       It is an internationally standardized programming language.

       It has both the features of high level languages as well as low level languages.

 

Advantages of C Language

       It is easy for debugging, testing and maintaining.

       It is a portable programming language. This means a program written for one computer may run successfully on another computer.

       It is fast for executing. This means that the executable program obtained after compiling and linking runs very fast.

       It is a compact programming language. The statements in C language are generally short but very powerful.

       It has only 32 Keywords so that's easy to remember.

       Its compiler is easily available.

       It has the ability to extend itself. Users can add their own functions to the C library.

 

Disadvantages of C Language

C programming language has no strong disadvantages. But it has some negligible disadvantages that are given below.

       There is no runtime checking.

       There is no strict type checking (for example we can pass an integer value for the floating data type).

       As the program extends it is very difficult to fix the bugs.

       It may compile time overhead due to the misplacing and excessive use of pointers.

       It does not support modern programming approaches like object oriented programming.

Text Box: Assignment - 1

1.     List out features of C programming language.

2.     List out advantages and disadvantages of C programming language.

 

Structure of C Program

Every C program contains a number of several building blocks known as functions. Each function performs tasks independently. The structure of C program is given below.

/* Comments * /

Preprocessors and Header Files

Function header

Global Declaration

void main()

{

Declaration part

Executable part

}

User defined functions

{

Body of user defined functions

}

Header Files

C program depends upon some header files for function definition that are used in the program. Each header file by default is extended with h. The file should be included using #include pre-processor directive. Example is given below.

#include<stdio.h>

 

Global Declaration

It declares some variables that are used in more than one function. These variables are known as global variables.

 

void main()

Every program of C language must contain the main () function. The main () is the starting point of every C program.

 

Declaration Part

It declares the variables that are used inside this particular function. The initialization of variables are also done in this section.

 

 

 

Executable Part

This part contains the statement blocks that may be input statement, process statement and output statement.

 

User defined functions

The functions defined by the user are called user defined functions. These functions are defined before or after the main() function.

 

Comments

It is not necessary in the program. However, to understand the flow of programs the programmer can include comments in a program.

 

Function header

It defines the heading or prototypes of the functions.

 

Example



Compiling Process

Step 1 Use a text editor like notepad to write your source code and save the file with extension dot c. For example: abc.c

 

Step 2 Compile the program using a compiler. If the compiler doesn't find any errors in the program, it produces an object file with .obj extension and the same name as the source code file (for example, test.c compiles to test.obj). If the compiler finds errors, it reports them. We must return to step 1 to make corrections in your source code.

 

Step 3 Link the program using a linker. If no errors occur, the linker produces an executable program located in a disk file with .exe extension and the same name as the object file (for example, test.obj is linked to create test.exe)

 

Step 4 Execute the program. We should test to determine whether it functions properly. If not, start again with step 1 and make modifications and additions to your source code.

 

 

 

 



 

 


 

Your First C Program

This demonstration uses a program named hello.c, which displays the words ‘Hello, World!’ on-screen. The source.code for hello.c is given below.

 

Example: Simple program showing ‘Hello World’.

1:  #include <stdio.h>

2:  void main()

3:   {

5:       printf("Hello, World\n");

5:   }

(Don't use the line number and colon sign on the program.)

 

1.     List out the major components of the C program?

2.     Draw a figure of the compilation process in C programming.

 

Header Files and C Preprocessor

Header Files are standard files of C-programming language. It contains the function definition of library functions. They are written at the top of the program. Some header files are given below.

POINTS TO REMEMBER

 

Header files are compulsory in language. That contains the function definition of library functions.

 

 

       #include<stdio.h>: It is a standard input output header file. It contains the function definition of input output functions such as scanf(), printf() etc.

 

       #include<conio.h>: It is a header file which is included in the program. This is used for  clrscr(), getch(), etc. We do not need to include this file in the C program. It is necessary for C++ programs. conio stands for CONsole Input Output header file. The clrscr() helps to clear the screen.

 

       #include<math.h>: This header file is used for mathematical functions such as pow(), sqrt(), sin(), tan() , cos() etc.

 

       #include<string.h> :It is string header file. It contains the function definition of string processing functions such as strlen(), strcat(), strcpy() etc.


 

C Preprocessor

Preprocessor is a program that processes the code before it passes through the compiler. It operates under the control of preprocessor command lines and directives. Preprocessor directives are placed in the source program before the main line, before the source code passes through the compiler. It is examined by the preprocessor for any preprocessor directives. If any appropriate actions are taken then the source program is handed over to the compiler.

POINTS TO REMEMBER

Preprocessor is a program that processes the code before it passes through the compiler. It operates under the control of preprocessor command lines and directives.

Preprocessor directives follow the special syntax rules and begin with the symbol # and do not require any semicolon at the end. A set of commonly used preprocessor directives are:

 

Directive

Function

#define

Defines a macro substitution and symbolic constant

#include

Specifies a file to be included in the program

 

Keywords

       C language: C language has been designed and developed by Dennis Ritchie at Bell Laboratories in 1972.

       Features of C language: C language is portable, procedural, general purpose, structured, standardized and compact programming Language.

       Disadvantages of C language: Some disadvantages of C language are no runtime checking, no strict type checking. It may be compile time overhead due to the misplacing and excessive use of pointers.

       Components of C: The main components of C are Comments, header files, function header, global declaration, main(), Declaration part, Executable part and user defined functions

       Header files: Header files are standard files that are compulsory in C program and contains the function definition of library functions

       Preprocessor: Preprocessor is a program that processes the code before it passes through the compiler. It operates under the control of preprocessor command lines and directives.


 1.     Why C is most popular language? Explain with suitable reasons.

2.     Explain compilation process with appropriate block diagram.

3.     Why are header files needed in every C program? Explain.

4.     Write down the importance of the header file and explain briefly about any three header files  of C language.

5.     What is a pre-processor? List any two preprocessors.

 

Netra Koirala

Netra Koirala

Computer Science Educator

Passionate computer science educator and author. Provides free study notes, practical guides, and tutorials for Class 9, 10, 11, 12, and B.Sc CSIT students in Nepal. Years of teaching experience in computer science fundamentals.

Computer Science notes, tutorials, MCQs, and educational resources for Nepal students. Covering Class 9, SEE preparation, Class 11, Class 12, SLC, programming, DBMS, networking, HTML, JavaScript, PHP, OOP and more.

Featured Post

Grade 10 Computer Science: Specification Grid & Model Questions

Specification Grid & Model Questions of Computer Science | Grade 10 📚 Examination Resource Specification Grid & M...

Followers