Download presentation
Presentation is loading. Please wait.
Published byFerdinand Horton Modified over 9 years ago
1
LESSON 1 Introduction to Programming Language
2
Computer Comprised of various devices that are referred to as HARDWARE. The computer programs that run of a computer are referred to SOFTWARE.
3
Computer Program Set of instructions used to operate a computer to perform specific task and produce result
4
Computer Programming Writing computer program
5
Programming Language Language used to create computer programs
6
Levels of Programming Languages Machine Languages Assembly Languages High Languages
7
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.
8
Assembly Language Uses symbolic names and operands instead of 1s and Os e.g. MOV and ADD Needs ASSEMBLER to translate instruction to machine level language
9
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
10
What is Compiler Translates the high level program(source code) into machine code(object code). High Level ProgramCompiler Machine Code 0,1
11
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++
12
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
13
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
14
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
15
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
16
Step 1: Start Step 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
17
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
20
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
21
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 Answer 1.Start 2.Accept dollar 3.Rials = dollar * 2.50 4.Display rials 5.Stop start Accept dollar rials = dollars * 2.50 Display rials stop
22
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 Answer 1.Start 2.Accept side, length, width 3.Square Area = side * side 4.Rectangle Area = length * width 5.Display square and rectangle area 6.Stop start Accept side, length, width Square area = side * side Rectangle area = length * width Display square and rectangle area stop
23
Exercises Question 3. Write an algorithm and draw the flowchart to determine if a number is positive or negative. Answer 1.Start 2.Accept number 3.If number<0 then Print “negative” else Print “positive” 4. Stop start Accept side, length, width Print “Positive” stop Print “Negative” If number<0 NO YES
24
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 Answer 1.Start 2.Accept side, length, width 3.Square Area = side * side 4.Rectangle Area = length * width 5.Display square and rectangle area 6.Stop start Accept side, length, width Square area = side * side Rectangle area = length * width Display square and rectangle area stop
25
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 Answer 1.Start 2.Accept side, length, width 3.Square Area = side * side 4.Rectangle Area = length * width 5.Display square and rectangle area 6.Stop start Accept side, length, width Square area = side * side Rectangle area = length * width Display square and rectangle area stop
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.