0% found this document useful (0 votes)
3 views14 pages

01-Introduction To Computer Programming

The document provides an introduction to computer programming, covering programming languages, the program development life cycle, and different number systems. It explains the distinction between high-level and low-level programming languages, as well as the steps involved in problem-solving through programming, including problem definition, analysis, algorithm design, coding, and debugging. Additionally, it includes examples of algorithms expressed in human language, flowcharts, and pseudocode.

Uploaded by

g2gcrzg4fm
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views14 pages

01-Introduction To Computer Programming

The document provides an introduction to computer programming, covering programming languages, the program development life cycle, and different number systems. It explains the distinction between high-level and low-level programming languages, as well as the steps involved in problem-solving through programming, including problem definition, analysis, algorithm design, coding, and debugging. Additionally, it includes examples of algorithms expressed in human language, flowcharts, and pseudocode.

Uploaded by

g2gcrzg4fm
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Computer

Programming I
(CSC111)
Prof. A. A. Karawia
1- Introduction to Computer Programming
Firstly, we will be giving a brief overview of programming
languages and the program development life cycle. Finally,
different number systems and conversions from one type to
another will be discussed.
1.1 Overview of Computer Programming Languages

1.1.1 What is a Programming Language?

A programming language is a standardized communication technique for


expressing instructions to a computer. Like human languages, each language has
its own syntax and grammar.
1.1.2 Categories of Programming Languages

❑ High-Level Languages
These languages are more abstract, easier to read and write, and closer to
human language. They require compilers or interpreters to convert them into
machine code.

Examples are Java, C, C++, Basic, Fortran


❑ Low-level Assembly Language
Assembly languages are like machine languages, but they are much easier to
program in because they allow a programmer to substitute names for numbers.
Assembly languages are available for each CPU family, and each assembly
instruction is translated into one machine instruction by an assembler
program.
Compiler
Or Assembler
Interpreter

Java-like Language Assembly Language Machine Language


High-level Language Low-level Language Low-level Language
English-like Mnemonics 1’s and 0’s

Fig. 1.1 High-level language and assembly language translation to machine language
1.1.3 The Program Development Life Cycle

❑ The basic steps in trying to solve a problem on the computer:

1- Problem Definition

Problem Analysis
2-

Algorithm design and representation (Pseudocode or flowchart)


3-

Coding and debugging


4-
1. Problem Definition

❑ The problem must be well and clearly defined first in terms of its input
and output requirements.
❑ A clearly defined problem is already half the solution.
❑Computer programming requires us to define the problem first before we
even try to create a solution.

2. Problem Analysis

❑ The problem must be formulated.


This step involves breaking up the problem into smaller and simpler subproblems.
Example Problem:
Determine the number of times a name occurs in a list
Input to the program:
list of names, name to look for
Output of the program:
the number of times the name occurs in a list
3. Algorithm design and representation

Definition: An algorithm is a set of clear and simple steps to solve a problem.


➢ It may be expressed in either Human language, through a graphical
representation like a flowchart or through a pseudocode

Expressing our solution through Human language:

1. Get the list of names


2. Get the name to look for, let's call this the keyname
3. Compare the keyname to each of the names in the list
4. If the keyname is the same with a name in the list, add 1 to the count
5. If all the names have been compared, output the result
Expressing our solution through a flowchart:
Start

Get
NameList

Get
KeyName

Count=0
No

No More Yes Name equal


Names? to KeyName?
Display Yes
Count
Count=Count +1
Stop

Figure 1.2: Example of a flowchart


Expressing our solution through pseudocode:

Let nameList = List of Names


Let keyName = the name to be sought
Let Count = 0
For each name in NameList do the following
if name == keyName
Count = Count + 1
Display Count

Figure 1.3: Example of a pseudocode


Table 1.1: Flowchart Symbols
1.1.4 Coding and Debugging
It is now possible to create the source code. Using the algorithm as basis, the
source code can now be written using the chosen programming language.

Definition:
Debugging is the process of finding and fixing errors (called bugs) in a program to
ensure it runs correctly.

❑ There are two types of errors:


1- Compile-Time Errors(Syntax errors) occur if there is a syntax error in the code.
2- Runtime Errors occur while the program is running. This is especially
true for logic errors such as infinite loops.

You might also like