Fifth Chapter Lesson-9 Basic concept of ‘C’ programming language

At the end of this lesson-

  • 1.You will be able to explain basic concept of ‘C’ programming language. 
  • 2. You will be able to describe the characteristics of ‘C’ programming language.
  • 3. You will be able to explain the basic structure of a ‘C’ program.
  • 4.You will be able to analyze different parts of a ‘C’ program. 

 

Basic concept of ‘C’ programming language: ‘C’ is a general-purpose, structured or procedure, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. It is also popular as mid level language. C was originally first implemented on the DEC PDP-11 computer in 1972. C is a successor of B language which was introduced around the early 1970s and B is successor of BCPL(BCPL-Basic Combined Programming Language) developed by Martins Richards.

C programming is considered as the base for other programming languages, that is why it is known as mother language. C language is considered as the mother language of all the modern programming languages because most of the programming languages for example, C++, Java, C#, etc. follow C syntax. It provides the core concepts like the array, strings, functions, file handling, etc. that are being used in many languages like C++, Java, C#, etc.

‘C’ is called structured or procedure oriented programming language:

‘C’ is called structured programming language. Because in ‘C’ program is divided into various small parts or modules which are known as function, method, routine, subroutine, etc.. Each module can be written separately and together it forms a single ‘C’ program. This structure makes it easy for testing, maintaining and debugging processes.

‘C’ is also called procedure oriented programming language. Because a procedural language breaks the program into function, method, routine, subroutine, etc. A procedural language specifies a series of steps for the program to solve the problem. In C, variables and function prototypes must be declared before being used.

C is considered as a middle-level language:

C is considered as a middle-level language because it supports the feature of both low-level and high-level languages. C language program is converted into assembly code, it supports pointer arithmetic (low-level), but it is machine independent (a feature of high-level). User can use C language to do System Programming (For writing Operating System) as well as Application Programming (For generating menu driven customer billing system) that is why it is called middle level language.

C is considered as a general purpose language:

The programming languages which can fulfill the needs of a wide variety of domains are called as general purpose programming languages. C is considered as a general purpose language because this language can fulfill more than one purpose, for example they can be apt for mathematical calculations, research work and application development at the same time.

 

Characteristics of C programming language:

  • 1. All C program starts from the main() function and it’s mandatory.
  • 2. C is case-sensitive; the use of uppercase letter and lowercase letter have different meanings.
  • 3. The statement in a C program ends with a semicolon.
  • 4. C is called Procedure-oriented programming language
  • 5. C is called Structured programming language
  • 6. C is called Mid-level programming language
  • 7. C is called General purpose language
  • 8. It is a robust language with rich set of built-in functions and operators that can be used to write any complex program.
  • 9. C is highly portable this means that programs once written can be run on another machines with little or no modification.
  • 10. Another important feature of C program, is its ability to extend itself.

 

Basic Structure of a ‘C’ program:

Documentation Section: This is an optional section. This section consists of comment lines which include the name of programmer, the author and other details like time and date of writing the program. Documentation section helps anyone to get an overview of the program. Comments can be written in two ways-

For multiple lines /*…….comments………*/

For single line //……..comments……….

Link Section: This section is mandatory for a program. The link section consists of the header files of the functions that are used in the program. It provides instructions to the compiler to link functions from the system library. Format of adding header file is-

 #include<header_file_name.h>.

Definition Section: All the symbolic constants are written in definition section. Macros are known as symbolic constants. Format for declaring a constant-

#define constant_name constant_value

Global Declaration Section: The global variables that can be used anywhere in the program are declared in global declaration section. This section also declares the user defined functions.

main() Function Section: It is necessary have one main() function section in every C program. It is user defined function because definition of this function is written by programmer. This section contains two parts, declaration and executable part. The declaration part declares all the variables that are used in executable part. These two parts must be written in between the opening and closing braces. Each statement in the declaration and executable part must end with a semicolon (;). The execution of program starts at opening braces and ends at closing braces.

Subprogram Section: The subprogram section contains all the user defined functions that are used to perform a specific task. These user defined functions are called in the main() function.

 

Explanation of different parts of a ‘C’ program:

Program Explanation:

1. #include<stdio.h> is used for using printf() and scanf() library functions in the execution section of the program. 

2. #include<conio.h>  is used for using getch( ) library functions in the execution section of the program.

3. It is necessary have one main() function in every C program. 

4. ‘{‘  indicates starts of the execution of program.

5. Three integer type variable for example x, y and sum have been declared. 

6. Taking two numbers in variable x and y using scanf() function.

7. Adding two numbers and assigning in variable sum. 

8. Printing value of sum using printf() function.

9. getch() library function has been used to hold the output in the console until user exit. 

10. ‘}’  indicates ends of the execution of program.

 

 

Lesson Evaluation-

Knowledge Based Questions:

a. What is header file?

Comprehension Based Questions:

  • b. Why ‘C’ programming language is called mid-level language?
  • b. ‘C language is a high level language’-explain.
  • b. ‘C is called Procedure-oriented programming language’-explain.
  • b. ‘C is called Structured programming language’-explain.
  • b. ‘C is called General purpose language’-explain.
  • b. ‘C language is a case sensitive language’-explain.
  • b. What do you understand by header file of a function in ‘C’ program? 
  • b. Write the importance of main() function in a ‘C’ program.
  • b. Why #include<stdio.h> is mandatory for a ‘C’ program?  

Creative Questions:

Multiple Choice Questions:

 


Written by,

Leave a Reply

Your email address will not be published. Required fields are marked *