(Grade IX) Chapter 7-Concept of Programming(Part 1)
Programming: It
is the process of providing detailed instructions to a computer step by step to
do specific tasks.
Programmer: A
programmer is a person who is involved in writing computer programs.
Types
of programming languages:
1.
High-level programming language and
2.
Low-level programming language
1.
High-level programming language
a.
These languages use structures and commands that resemble human language,
making them easier for people to understand.
b.
Programs written in high-level languages are called program code, and they’re
readable to humans but not to computers.
2.
Low-level programming language
a.
Low-level languages mainly consist of 0s and 1s, which are directly understood
by computers.
b.
Programs are written in the form of machine code
To
make high-level language programs understandable to computers, they need to be
converted into low-level programming languages. This conversion is done using
language translators like interpreters and compilers.
The
table below shows the difference between compiler and interpreter.
|
Compiler |
Interpreter |
|
A compiler reads and translates program code to machine code all at
once. |
An interpreter reads and translates program code to machine code
line by line. |
|
If there’s an error in the program code, it displays errors at the
end. |
If there is an error in the program code, it displays while running
the program. |
|
Compiled program’s execution time is comparatively faster. |
Interpreted program’s execution time is comparatively slower. |
|
Compiled programs have separate files to store machine code. |
An interpreted program does not have a separate file to store
machine code. |
Algorithm
●
An algorithm is a set of step-by-step instructions designed to solve a specific
problem or perform a particular task.
●
It begins with “start” and ends with “stop.”
●
The instructions are written in simple, general language (like spoken
languages).
Flowchart
●
A flowchart is defined as the pictorial and graphical representation of an
algorithm.
●
It utilizes shapes (oval, rectangle, parallelogram, etc.) to depict various
elements.
●
The shapes have distinct meanings in a flowchart.
●
The flowcharts correspond to algorithms, visually representing their steps and
structure.
The table
below shows shapes used in flowchart and their meaning:
|
Name |
Shapes |
Meaning |
Uses |
|
Oval |
|
Start/End |
Marks the
start and end points of a flowchart. |
|
Rectangle |
|
Processing |
Represents
processing or calculation steps in the flow. |
|
Arrow |
|
Direction of
flow |
Shows the
direction of flow or sequence in the flowchart. |
|
Diamond |
D e c i s i o
n / C o n d i t i o n Check |
Checks
conditions and represents decision-making points. |
|
|
Parallelogram |
|
Input/Output |
Handles
input/output, taking user input and displaying output. |
|
Circle |
|
Connector |
Act as a
connector joining components of the flow chart. |
Write algorithm and draw flowchart of following:
a. To calculate the volume of a room
1. Start
2. Input length (L), width (W), and height (H) of the room
3. Calculate volume: `Volume = L × W × H`
4. Display `Volume`
5. Stop
b. To convert distance from meters to centimeters
1. Start
2. Input distance in meters (`M`)
3. Calculate `Centimeters = M × 100`
4. Display `Centimeters`
5. Stop
c. To calculate the area and perimeter of a room
1. Start
2. Input length (L) and width (W)
3. Calculate area: `Area = L × W`
4. Calculate perimeter: `Perimeter = 2 × (L + W)`
5. Display `Area` and `Perimeter`
6. Stop
d. To display the smallest number among three numbers
1. Start
2. Input three numbers: `A`, `B`, `C`
3. If `A < B` and `A < C`, then `Smallest = A`
4. Else if `B < C`, then `Smallest = B`
5. Else `Smallest = C`
6. Display `Smallest`
7. Stop
e. To display the greatest number among two numbers
1. Start
2. Input two numbers: `X`, `Y`
3. If `X > Y`, then `Greatest = X`
4. Else `Greatest = Y`
5. Display `Greatest`
6. Stop
f. To display whether a number is divisible by 13
1. Start
2. Input number `N`
3. If `N mod 13 = 0`, display "Divisible by 13"
4. Else display "Not divisible by 13"
5. Stop
g. To display all numbers from 2 to 50
1. Start
2. For `i = 2` to `50`
Display `i`
3. End loop
4. Stop
h. To display the sum of all numbers from 1 to 50
1. Start
2. Initialize `Sum = 0`
3. For `i = 1` to `50`
`Sum = Sum + i`
4. End loop
5. Display `Sum`
6. Stop
i. To display the sum of any ten numbers given by the user
1. Start
2. Initialize `Sum = 0`
3. For `i = 1` to `10`
Input `Num`
`Sum = Sum + Num`
4. End loop
5. Display `Sum`
6. Stop
j. To count even and odd numbers separately among ten numbers
1. Start
2. Initialize `EvenCount = 0`, `OddCount = 0`
3. For `i = 1` to `10`
Input `Num`
If `Num mod 2 = 0`, `EvenCount = EvenCount + 1`
Else `OddCount = OddCount + 1`
4. End loop
5. Display `EvenCount` and `OddCount`
Book Exercise Page number:219
Write
the full forms of the following:
a.
MLL – Machine Level Language
b.
4GL – Fourth Generation Language
c.
5GL – Fifth Generation Language
d.
SQL – Structured Query Language
e.
SDLC – System Development Life Cycle
Multiple
Choice Questions:
a.
The set of rules that should be followed by the programmers while writing
programs is called
i.
semantic
ii.
format
iii. syntax
iv.
protocol
b.
Which of the following programming language uses 0's and 1's to write
instructions?
i.
Assembly
ii. Machine
iii.
High level iv.
iv.
4 GL
c.Which
of the following programming language uses mnemonic codes to C. write programs?
i. Assembly
ii.
Machine
iii.High
level
iv.4
GL
d.
Machine level language is considered as ....... generation programming
language.
i.first
ii.
second
iii.
third
iv.
fourth
e.
Which of the following language processor translates high level language into
machine level language, all at once?
i.Intrepreter
ii. Compiler
iii
Asssembler
iv.
All of above
f.
Which of the following programming language is machine independent
i.Assembly
ii.Machine
iii.
High level
iv.
Low level
g.The
pictorial representation of the set of instructions is called.
iΓ.Algorithm
ii. Flowchart
iii.
Pseudocode
iv.
Chartflow
h.
The software testing in which the tester does not have the knowledge and access
to the source code is called testing.
i.
Black box
ii.
Gray box
iii.
White box
iv.
Red box
Write
the technical terms for each description:
a.
The set of instructions that is given to the computer to perform the desired
task – Program
b.
The language that uses 0's and 1's to write programs – Machine Level Language
c.
The person who writes programs in order to develop software – Programmer
d.
Software that translates programs written in high-level language into
machine-level language, line by line – Interpreter
e.
Program that is converted into machine-level language – Object Program
f.
A stepwise finite list of instructions used in solving problems or performing
tasks – Algorithm
g.
Pictorial representation that shows the logical flow of the program – Flowchart
h.
Error or mistake that is present in the program – Bug
i.
A method of software testing that tests internal structures or workings of an
application – White Box Testing
j.
The process of writing the programs – Coding
Short
Answer Questions:
a.
What is programming language? List the different types of programming language.
A
programming language is a set of instructions and rules used to write programs
that tell a computer what to do.
Types
of programming languages:
1.
Machine Level Language
2.
Assembly Level Language
3.
High-Level Language
4.
Fourth Generation Language (4GL)
5.
Fifth Generation Language (5GL)
b.
What is syntax?
Syntax
refers to the set of rules that define the correct structure or format of
statements in a programming language. It determines how commands and symbols
must be arranged for the program to work correctly.
c.
Differentiate between compiler and interpreter.
pg 218
d.
Define algorithm and flowchart.
Algorithm:
A step-by-step procedure or set of rules used to solve a problem or perform a
task.
Flowchart:
A pictorial or graphical representation of an algorithm that shows the logical
flow of a program using symbols.
e.
What is testing? List its types.
Testing
is the process of checking and verifying that a program or software works
correctly and is free of errors.
Types
of testing:
1.
Black Box Testing
2.
White Box Testing
3.
Gray Box Testing
f.
What is source code and object code?
Source
Code: The original program written by a programmer in a high-level language.
Object
Code: The translated version of the source code into machine language, produced
by a compiler or assembler.
Long
Answer Questions:
a.
Explain Machine Level Language and High-Level Language with their merits and
demerits.
1.
Machine Level Language (MLL):
Definition:
Machine Level Language is the lowest-level programming language that consists
of binary code (0’s and 1’s) directly understood by a computer’s CPU.
Merits:
1. Programs run very fast as they are directly executed by the CPU.
2. No need for a translator.
Demerits:
1. Difficult to learn and write.
2. Not portable; works only for a specific type of computer.
3. Hard to debug and maintain.
2.
High-Level Language (HLL):
Definition:
High-Level Language is a programming language that uses human-readable
instructions, such as C, Java, or Python, which are later translated into
machine code using a compiler or interpreter.
Merits:
1. Easier to learn, write, and understand.
2. Portable across different computer systems.
3. Reduces programming time and effort.
Demerits:
1. Slower execution compared to machine language.
2. Requires a compiler or interpreter to convert code into machine language.
b.
List the different symbols used in the flowchart along with their functions.
notes