Professional Documents
Culture Documents
Is an electronic device which operates on data, analysis the data and then applies
the instruction to this data in order to perform a particular task.
The term hardware refers to the physical components of your computer such as
the system unit, mouse, keyboard, monitor etc.
Operating System
The operating system is a special type of program that loads automatically when
you start your computer. It allows you to use the advanced features of a modern
computer without having to learn all the details of how the hardware works.
Examples: Windows, Linux, Unix and Mac OS, etc.,
An operating system performs basic tasks such as,
In every programming Language there are sets of rules that govern the symbols
used in a programming language. These set of rules determine how
the programmer can make the computer hardware to perform a specific
operation. These sets of rules are called syntax.
Programming Language is a set of rules, symbols, and special words used to construct a
computer program. Programming language rules consists of:
Rules of Syntax which specify how valid instructions are written in the language.
Rules of Semantics which determine the meaning of the instructions (what the
computer will do).
Computer Programs vary in size from very small to extremely large. Programming
languages are categorized into three main types, these are:
Machine languages
Assembly languages
High level languages(HLL)
1. Machine Language: is a low level language in which its instructions are string of binary
representation that a computer's hardware can perform.
e.g. 00000000 100101 0100 1000 0100 1001
2. Assembly Language: it is also a low-level programming language in which a mnemonic or
a symbol is used to represent each of the machine language instructions for a specific
computer. Assembly language programs also allow the user to use text names for data
rather than having to remember their memory addresses. The Assembly language is
translated into the machine language through an Assembler.
Problem Solving with a computer involves developing computer programs which are
very complex and creating large programs may include making millions of individual
decisions. Therefore problem solving with computers involves several steps
1. Clearly define the problem.
2. Analyze the problem and formulate a method to solve it
3. Describe the solution in the form of an algorithm.
4. Draw a flowchart of the algorithm.
5. Write the computer program.
6. Compile and run the program (debugging).
7. Test the program (debugging)
8. Interpretation of results.
1.4. Verification and Validation
If the program has an important application, for example to calculate student grades or
guide a rocket, then it is important to test the program to make sure it does what the
programmer intends it to do and that it is actually a valid solution to the problem. The tests are
commonly divided as follows:
Verification: verify that program does what you intended it to do; steps 7(8) above
attempt to do this.
Validation: does the program actual solve the original problem i.e. is it valid? This goes
back to steps 1 and 2 - if you get these steps wrong then your program is not a valid
solution.
1.5. Algorithm
1. Psedocode
Algorithm
Step 1: Input two numbers say N1 and N2
Step 2: Calculate the sum N1 + N2
Step 3: out put the sum
Psedocode
Input N1 and N2
Add N1 and N2
Output N1 and N2
Example 2: Write an algorithm to determine a student’s final mark and indicate
whether it is passing or failing. The final mark is calculated as the average of six marks
Algorithm
Step 1: Input the six marks M1, M2, M3, M4, M5, M6
Step 2: Calculate the average of the six marks
Average=( M1, M2, M3, M4, M5, M6 )/ 6
Step 3: Check if the Average is greater than 50.
Step 4: if the average is greater than 50 then print (Output) Pass else i.e. if it is below 50
then print Fail.
Psedocode
Input M1, M2, M3, M4, M5, M6
Calculate Average= (M1, M2, M3, M4, M5, M6)/ 6
If average is below 50
Print “FAIL”
Else
Print “PASS”
Exercise: Write an algorithm and psedocode for the following problems
a. Take a number and calculate the factorial of that number
b. Take a number and prints “odd” if the number is odd otherwise prints “even”
c. Calculate the CGPA of a student. (The student should enter grade for the five
subjects along with the respective credit hour).
2. Flowcharts
A flow chart is the logical flow of the solution in a diagrammatic form, and provides a
plan from which the computer program can be written. The logical flow of an algorithm can
be seen by tracing through the flowchart. Some standard symbols used in the formation of flow
charts are given below.
Flow Chart Symbols
Example 1: Write an algorithm, in flow chart form that take two numbers and output
the sum of the two numbers.
Algorithm
Step 1: Input two numbers say N1 and N2
Step 2: Calculate the sum N1 + N2
Step 3: out put the sum
Flow chart
Start
Input N1
Input N2
Psedocode
Input N1 and N2
Add N1 and N2
Sum=N1+N2 Output N1 and N2
Display Sum
End
Example 2: Write an algorithm in flow chart form to determine a student’s final mark
and indicate whether it is passing or failing. The final mark is calculated as the average
of six marks.
Flow chart
Start
Average = (N1+N2+N3+N4+N5+N6)/6
No
Is Average >=50
Yes
End
E.g.3. To take out the sum of even numbers among the numbers from 1 up to a given
number
Start
Ctr=1 Sum=0
Input Num
False Print
Ctr<=Num
Sum
True
End
False
Ctr%2==0
Tru
Ctr=Ctr+1
Sum=Sum+Ctr
Exercise