![Page 1: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/1.jpg)
LESSON 1
Introduction to Programming Language
![Page 2: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/2.jpg)
ComputerComprised of various devices that are referred to as HARDWARE.
The computer programs that run of a computer are referred to SOFTWARE.
![Page 3: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/3.jpg)
Computer ProgramSet of instructions used to operate a computer to perform specific task and produce result
![Page 4: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/4.jpg)
Computer ProgrammingWriting computer program
![Page 5: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/5.jpg)
Programming LanguageLanguage used to create computer programs
![Page 6: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/6.jpg)
Levels of Programming Languages
Machine LanguagesAssembly LanguagesHigh Languages
![Page 7: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/7.jpg)
Machine Language
Lowest level of computer languages
Only language that computer can understand.
Consist entirely of 1s and 0s. Easily understood by computers
but difficult to read by people.
![Page 8: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/8.jpg)
Assembly LanguageUses symbolic names and operands instead of 1s and Os e.g. MOV and ADD
Needs ASSEMBLER to translate instruction to machine level language
![Page 9: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/9.jpg)
High-Level Languages English like language instructions
so it is easier to learn, use and debug the program.
Example FORTRAN, COBOL, BASIC, PASCAL, C,
C++ and JAVA It needs the help of COMPILER to
be understood by the computer
![Page 10: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/10.jpg)
What is Compiler Translates the high level
program(source code) into machine code(object code).
High Level Program Compiler Machine Code0,1
![Page 11: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/11.jpg)
History of C++ In 1970s, at Bell Laboratories, Dennis
Ritchie and Brian Kernighan designed the C programming language.
Most of C is a subset of C++ C++ was developed by Dr. Bjarne
Stroustrup in 1985 at AT&T Bell Labs New Jersey, USA.
Initially called as “C with classes” but was change to C++
![Page 12: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/12.jpg)
An ALGORITHM is a detailed sequence of simple steps that are needed to solve a problem.
An algorithm is defined as a step-by-step sequence of instructions that describes how the data are to be processed to produce the desired outputs.
Algorithm
![Page 13: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/13.jpg)
1. Start 2. Accept num1, num2 3. sum = num1+num2 4. Display sum 5. Stop
Write an algorithm to find sum of two numbers.
Sample 1
![Page 14: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/14.jpg)
1. Start 2. Accept q1, q2, q3 3. total = q1 + q2 + q3 4. average = total / 3 5. Display total, average 6. Stop
Write an algorithm find the total and average of three quizzes.
Sample 2
![Page 15: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/15.jpg)
Write an algorithm to determine a student’s final grade and indicate whether it is passing or failing. The final grade is calculated as the average of four marks.
Sample 3
![Page 16: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/16.jpg)
Sample 3
Step 1: StartStep 2: Input M1, M2, M3, M4 Step 3: GRADE = (M1+M2+M3+M4)/4 Step 4: if (GRADE < 50) then Print “FAIL”
else Print “PASS” Step 5: Stop
![Page 17: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/17.jpg)
A flowchart is a design tool used to graphically represent the logic in a solution. It is a pictorial representation or graphical representation of the algorithm.
Flowchart
![Page 18: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/18.jpg)
Flowchart
![Page 19: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/19.jpg)
Flowchart
![Page 20: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/20.jpg)
Write a flowchart to find sum of two numbers
Sample 1
1. Start 2. Accept num1, num2 3. sum = num1+num2 4. Display sum 5. Stop
![Page 21: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/21.jpg)
Exercises Question 1. Write an algorithm and draw
the flowchart to read money in US dollar and convert to Omani rials. rials = dollar * 2.50
Answer1. Start2. Accept dollar3. Rials = dollar * 2.504. Display rials5. Stop
start
Accept dollar
rials = dollars * 2.50
Display rials
stop
![Page 22: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/22.jpg)
Exercises Question 2. Write an algorithm and draw
the flowchart to calculate area of square and rectangle. Square Area = side * side Rectangle Area = length * width
Answer1. Start2. Accept side, length, width3. Square Area = side * side4. Rectangle Area = length *
width5. Display square and
rectangle area6. Stop
start
Accept side, length, width
Square area = side * sideRectangle area = length *
widthDisplay square and rectangle
areastop
![Page 23: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/23.jpg)
Exercises Question 3. Write an algorithm and draw
the flowchart to determine if a number is positive or negative.
Answer1. Start2. Accept number3. If number<0 then
Print “negative” else
Print “positive”4. Stop
start
Accept side, length, width
Print “Positive”
stop
Print “Negative
”
If number
<0 NOYES
![Page 24: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/24.jpg)
Exercises Question 2. Write an algorithm and draw
the flowchart to calculate area of square and rectangle. Square Area = side * side Rectangle Area = length * width
Answer1. Start2. Accept side, length, width3. Square Area = side * side4. Rectangle Area = length *
width5. Display square and
rectangle area6. Stop
start
Accept side, length, width
Square area = side * sideRectangle area = length *
widthDisplay square and rectangle
areastop
![Page 25: LESSON 1 Introduction to Programming Language. Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that](https://reader036.vdocuments.us/reader036/viewer/2022062906/5a4d1b307f8b9ab05999b087/html5/thumbnails/25.jpg)
Exercises Question 2. Write an algorithm and draw
the flowchart to calculate area of square and rectangle. Square Area = side * side Rectangle Area = length * width
Answer1. Start2. Accept side, length, width3. Square Area = side * side4. Rectangle Area = length *
width5. Display square and
rectangle area6. Stop
start
Accept side, length, width
Square area = side * sideRectangle area = length *
widthDisplay square and rectangle
areastop