




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Lecture notes for computer programming basics. It gives step by step from basics to object oriented programming
Typology: Lecture notes
1 / 106
This page cannot be seen from the preview
Don't miss anything!





























































































Project No: EE103-FALL-2011 Group No: EE103-FY- Revision: C Revision Date: 26/12/2011 Amr M. Gody
Revision C 01 C02 C03 C04 C05 C0 6
Purpose Add Add Add Add Add Add Date 31/10/2011 5/11/2011 18/11/2011 12/12/2011 19/12/2011 26/12/
By
Amr M. Gody
Amr M. Gody
Amr M. Gody
Amr M. Gody
Amr M. Gody
Amr M. Gody Checked Approved
Revision Date: 26/12/2011 Amr M. Gody
Project No: EE103-FALL-2011 Group No: EE103-FY- Revision: C Revision Date: 26/12/2011 Amr M. Gody
Preface Thank you for Dr. Magdy Amer for his contribution in adding problems into the sheets of OOP.
Project No: EE103-FALL-2011 Group No: EE103-FY- Revision: C Revision Date: 26/12/2011 Amr M. Gody
Popular numbering systems are: Decimal Binary Hexadecimal Octal
Base is 10 The number is defined as a multiple of 10 digits 104 103 102 101 100. 10 -^1 10 -^2
Each digit contains a number that define the multiple of the base unit indicated in the above figure. For example 586 5 * 10^2
Base is 2 The number is defined as a multiple of 2
The number is defined as a multiple of 10 digits 24 23 22 21 20. 2 -^1 2 -^2
Each digit contains a number that define the multiple of the base unit indicated in the above figure. For example 101 1 * 2^2
Project No: EE103-FALL-2011 Group No: EE103-FY- Revision: C Revision Date: 26/12/2011 Amr M. Gody
Base is 16 The number is defined as a multiple of 16
The number is defined as a multiple of 10 digits 164 163 162 161 160. 16 -^1 16 -^2
Each digit contains a number that define the multiple of the base unit indicated in the above figure. For example 101 1 * 2^2
Base is 8 The number is defined as a multiple of 8
The number is defined as a multiple of 10 digits 84 83 82 81 80. 8 -^1 8 -^2
Each digit contains a number that define the multiple of the base unit indicated in the above figure.
This way we define the number in terms of multiple of base 8. The maximum number that we can fit in one digit is 7.
Figure 1-1 illustrates three numbering systems side by side. Numbering systems is used to give different view for the same quantity. The relation should be kept in mind. For example consider the Hex – Binary relation as in Table 1
The hex number is very important to describe large numbers. Each hex digit is 4 binary digits.
Table 1 - 1 : HEX-Binary-Octal Equivalent for certain number
A 0 B 5 1 0 1 0 0 0 0 0 1 0 1 1 0 1 0 1 1 2 0 2 6 5
Project No: EE103-FALL-2011 Group No: EE103-FY- Revision: C Revision Date: 26/12/2011 Amr M. Gody
Project No: EE103-FALL-2011 Group No: EE103-FY- Revision: C Revision Date: 26/12/2011 Amr M. Gody
Project No: EE103-FALL-2011 Group No: EE103-FY- Revision: C Revision Date: 26/12/2011 Amr M. Gody
Let us get a close image about computer architecture.
Figure 1 - 2 : Fundamental components of the computer system.
Figure 1-2 illustrates the fundamental components of computer. It consists of three parts
The control is achieved through three channels each called bus.
The microprocessor itself consists of almost similar structure.
Registers
Memory
Peripheral Devices
Project No: EE103-FALL-2011 Group No: EE103-FY- Revision: C Revision Date: 26/12/2011 Amr M. Gody
Section 2.1 illustrates the static structure of the computer system. The dynamic structure means the active computer running a program. The program is the user algorithm to be run by the computer for solving certain problem.
The program is sequence of instructions that are understood by the computer. Let us discuss the program in more details.
The program is put into the memory, so what is the memory itself. The memory is a small array of single binary digits. Table 1-2 views a part of memory. This part is 6 bytes.
Table 1 - 2 : Memory Array of bits
Address in hex D7 D6 D5 D4 D3 D2 D1 D 0F235 1 1 0 0 0 0 0 1 0F236 0 0 0 0 0 0 0 0 0F237 1 1 1 1 0 1 0 0 0F238 1 1 1 1 0 1 0 1 0F239 0 0 0 0 0 1 1 1 0F23A 0 0 0 0 0 0 0 0
The byte is a memory measurer. One byte = 8 bits.
Each bit can store a single binary digit. It is one of two states 1- State 1. 2- State 0.
Each state can be encoded into a certain voltage level. For example state 0 = 0 (v) and State 1 = 5 (v)
Each byte is a collection of 8 bits. Each byte has a unique address.
Project No: EE103-FALL-2011 Group No: EE103-FY- Revision: C Revision Date: 26/12/2011 Amr M. Gody
Interfacing with PC means connecting devices to the CPU. This is the key of almost all modern technologies that consider the Microprocessor as a smart engine. Adding smart device to the hardware makes it more flexible to make off sure decisions. The device can make the decision based on a program. We can say that adding such smart engines to the devices is the key for the modern age. Figure 2-2 illustrates the layout of the interfacing with CPU. To interface any device to the CPU you should build interfacing circuit to match the electrical signals needed to make the device communicating with the CPU. The Controlled valve in figure 1-3 is controlled by sending appropriate electric signal to the device to control the open or control percentage. The CPU sends required opening percentage to the data memory at specific address. Then it asks the interface board to write that percentage to the valve using the control memory. This is achieved by sending certain word of bits that encodes the required information to the control memory. Then the interface board will de-code the information in control word and the data in the data memory to suitable electric signal to open the valve with the percentage required. The device send the status using some limit switches to the interface circuit, which in turn encode the information to creating pattern of bits and put it into the status memory. Then the interface board notifies the CPU with the status.
Figure 1 - 3 : Interfacing layout.
The Personal computer is a collection of devices that are connected to CPU. They are integrating through the special program called the operating system.
Project No: EE103-FALL-2011 Group No: EE103-FY- Revision: C Revision Date: 26/12/2011 Amr M. Gody
Project No: EE103-FALL-2011 Group No: EE103-FY- Revision: C Revision Date: 26/12/2011 Amr M. Gody
The program is a flow of activities. There are 3 types of activities
The program is a sequence of the mentioned activities. The flow chart is invented to provide simple and standard method to express the program flow.
The first step for implementing idea is to express it into flow chart. It is language independent method to express the idea.
The shape is used to indicate the start and end points in the program flow. Example
Start node
End node
View result
Find enclosing angle
Project No: EE103-FALL-2011 Group No: EE103-FY- Revision: C Revision Date: 26/12/2011 Amr M. Gody
This shape is used to express the data for the process and for the subroutines. This makes it easier for the reader to trace the data flow along the program.
Example
A : Vector B : Vector C : Vector N : Vector size