24 Programming and Data Structures
The following statements are valid.
a=b+c;
d=b*c;
or
a=b+c; d=b*c;
4) The opening and closing braces should be balanced, that is, for example, if opening braces are
four then closing braces should also be four.
1.14 EXECUTING THE PROGRAM
The following steps are essential in executing a program in C.
a) Creation of a program: The program should be written in C editor. The file name does not
necessarily include the extension '.C/ The default extension is '.C.' The user can also specify
his/her own extension.
b) Compilation and linking a program: The source program statements should be translated into
object program, which is suitable for execution by the computer. The translation is done after
correcting each statement. If there is no error, compilation proceeds and the translated program
is stored in another file with the same file name with extension '.obj.' If at all errors are there the
programmer should correct them. Linking is also an essential process. It puts all other program
files and functions which are required by the program together. For example, if the programmer
is using pow () function, then the object code of this function should be brought from math.h
library of the system and linked to the main () program.
c) Executing the program: After the compilation, the executable object code will be loaded in the
computer's main memory and the program is executed. All the above steps can be performed
using menu options of the editor.
SUMMARY
In this chapter, you have studied the basics of algorithm, sequence, selection, iteration, flowchart
and basics of a C program. In addition, you are exposed to classification of algorithms and
pseudocode. You have also studied the roles of interpreter and compiler and the distinction between
them. This chapter mentions the various sections of a program and rules that can be adopted while
writing a program. Distinction is also made between iteration and recursion.
EXERCISES
A) Answer the following questions.
1) Explain iteration and recursion.
2) What are the functions of an interpreter and a compiler?
3) What is the difference between an interpreter and a compiler?
4) What is meant by compilation? Explain in detail.
5) Write the rules for writing a C program.
6) Elaborate the different sections of a C program.