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.
Program Development Styles and Basics of C 25
7) Explain the functions of a linker.
8) What is the role of ({}) curly braces in a C program?
9) What are the user-defined functions?
10) Explain classification of algorithms.
11) Narrate program mythologies.
12) What is pseudocode? Give an example of pseudocode for drawing a flowchart.
13) What is a flowchart? Explain its necessity.
14) Describe various symbols of flowcharts.
B) Choose the co rrect op tion fo r each o f the follo w in g questions.
1) The C programs are converted into machine language using
a) an assembler
c) an interpreter
2) The C programs should be written only in
a) lower case
c) title case
b) a compiler
d) an operating system
b) upper case
d) sentence case
3) The role of a compiler is to translate the source program statements to
octal codes
none of the above
.d
.exe
comma (,)
curly brace ({})
a) object codes b)
c) decimal codes d)
4) The extension for C program files by default is
(a) .c b)
(c) .obj d)
5) The C programs are highly portable means
a) same program executes on different computers
b) program executes only on the same computer
c) program needs a lot of modification to run
d) none of the above
6) Each instruction in a C program is terminated by
a) dot (.) b)
c) semi-colon (;) d)
7) Which one of the following statements is incorrect?
a) a compiler compiles the source program
b) an assembler takes an assembly program as input
c) a compiler does the same type of function as an interpreter
d) none of the above
8) The program which translates a high level program into its equivalent machine language
program is called
a) transformer b)
c) converter d)
9) An interpreter reads the source code of a program
a) one line at a time b)
c) complete program in one stroke d)
10) A compiler compiles the source code
a) complete program in one stroke b)
c) two lines at a time d)
language processor
none of the above
two lines at a time
none of the above
one line at a time
none of the above
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.237.164