Computer Programming Lecture1
Computer Programming Lecture1
Computer Programming Lecture1
Safa Hussain
What is the computer:
0The computer is a device that operated upon information or data. It is an
electronic device which accepts inputs data, stores the data, does arithmetic
and logic operations and provides the outputs in the desired format. The
computer receives data, process it, produces output and stores it for further
references. So, a computer should have at least four major components to
perform these tasks. A block diagram of the basic computer organization has
the following functional units.
A set of commands that are given to the computer to perform a specific work
in a way that the computer understands. For example, give the computer a
command to print a sentence or run a calculation in a way that the computer
calculates.
Programming languages:
In other term:
Machine languages
machine language is the binary language made of 1s and 0s is
executed directly by a computer. It is difficult, dependent on the type of
machine. Difficult to correct the errors
Assembly languages
High-level languages
high-level language is a programming language such as C, FORTRAN,
or Pascal that enables a programmer to write programs that are more
or less independent of a particular type of computer. Such languages
are considered high-level because they are closer to human languages
and further from machine languages.
Algorithm:
algorithm can be defined as a finite sequence of effect statements to solve a
problem. An effective statement is a clear, unambiguous instruction that can
be carried out.
Algorithm properties:
•Finiteness : the algorithm must terminate a finite number of steps.
• Non-ambiguity: each step must be precisely defined. At the completion of
each step the nest step should be uniquely determined .
•Effectiveness: the algorithm should solve the problem in a reasonable
amount of time.
1.Start
2.Input first number
3.Input second number
4.If second number <>0 Goto 6
5.If second number=0 Goto 9
6.Calculate division
7.Print the result
8.Goto 10
9.Print error
10.end
1.Start
2.Initialize two variables (count and sum), set count to 0 ,sum to 0
3.Input number.
4. increment the counter of input numbers
5.If the number is negative go to 7
6.If the number is positive go to 8
7.Add the number to the sum.
8.if the counter less than 50 go to 3
9. print sum
10. End
A flowchart