CSE 163 Programming C 1 CSE 163 Evaluation

  • Slides: 16
Download presentation
CSE 163 Programming C 1

CSE 163 Programming C 1

CSE 163 Evaluation n n Attendance, Assignment / Oral Presentation………………… 10% Class Quizzes……………. .

CSE 163 Evaluation n n Attendance, Assignment / Oral Presentation………………… 10% Class Quizzes……………. . 20% Mid Term Exam…………. . 30% Final Exam………………. 40% Total………………. 100% 2

What is a Programming Language n n A programming language is used to write

What is a Programming Language n n A programming language is used to write computer programs such as: Applications Utilities Servers Systems Programs A program is written as a series of human understandable computer instructions that can be read by a compiler and linker, and translated into machine code so that a computer can understand run it. 3

Syntax and Semantics Syntax: n Syntax refers to the ways symbols may be combined

Syntax and Semantics Syntax: n Syntax refers to the ways symbols may be combined to create wellformed sentences (or programs) in the language. Syntax defines the formal relations between the constituents of a language. n Syntax provides a structural description of the various expressions Semantics: n Semantics reveals the meaning of syntactically valid strings in a language. n For programming languages, semantics describes the behavior that a computer follows when executing a program in the language. 4

Algorithms n n An algorithm is an effective method for solving a problem using

Algorithms n n An algorithm is an effective method for solving a problem using a finite sequence of instructions. Algorithms are used for calculation, data processing, and many other fields. 5

Algorithms (Cont. ) 6

Algorithms (Cont. ) 6

Algorithms (Cont. ) n Example: The program computes the sum, average and product of

Algorithms (Cont. ) n Example: The program computes the sum, average and product of three numbers: Step Step 1: 2: 3: 4: 5: Read X, Y, Z S=X+Y+Z A= S / 3 P= X x Y x Z Write S, A, P 7

Flowchart n Flowchart is the graphical representation of the steps of an algorithm Start/End

Flowchart n Flowchart is the graphical representation of the steps of an algorithm Start/End Input/Output Process Decision Connector 8

Flowchart (Cont. ) n Example: The program computes the sum, average and product of

Flowchart (Cont. ) n Example: The program computes the sum, average and product of three numbers: Start Read X, Y, Z S=X+Y+Z A=S/3 P=X×Y×Z Write S, A, P End 9

Flowchart (Cont. ) n Example: The program computes the larger one between two Start

Flowchart (Cont. ) n Example: The program computes the larger one between two Start numbers: Read X, Y X>Y No Write Y Yes Write X End 10

Flowchart (Cont. ) n Count loop flowchart Enter Loop K=1 Process (s) K =

Flowchart (Cont. ) n Count loop flowchart Enter Loop K=1 Process (s) K = K+1 Yes K < =10 No Exit Loop 11

Pseudocode n Pseudocode is a compact and informal high-level description of a computer programming

Pseudocode n Pseudocode is a compact and informal high-level description of a computer programming algorithm intended for human reading rather than machine reading Example: The program computes the sum, average and product of three numbers: Read X, Y, Z Compute Sum (S) as X + Y + Z Compute Average (A) as S / 3 Compute Product (P) as X x Y x Z Write (Display) the Sum, Average and Product 12

Pseudocode (Cont. ) n Example The example below shows the Pseudocode for a program

Pseudocode (Cont. ) n Example The example below shows the Pseudocode for a program that reads two numbers and displays the numbers read in decreasing order: Read A, B If A is less than B BIG=B SMALL = A else BIG=A SMALL = B Write (Display) BIG, SMALL 13

Pseudocode (Cont. ) n Program to computes the average of few numbers set average

Pseudocode (Cont. ) n Program to computes the average of few numbers set average to zero set count to zero set total to zero read number while ( not end-of-data ) increment count by 1 total = total + number read number if ( count>0)then average = total / count display average 14

Programming Steps n Problem-Solving Phase 1. Analysis and specification. (Define problem and what solution

Programming Steps n Problem-Solving Phase 1. Analysis and specification. (Define problem and what solution must do. ) 2. General solution (algorithm). (Develop logical sequence of steps to solve problem. ) 3. Verify. (follow steps - by hand. ) 15

Programming Steps (Cont. ) n n Implementation Phase 1. Specific solution (program). (Translate algorithm

Programming Steps (Cont. ) n n Implementation Phase 1. Specific solution (program). (Translate algorithm to code. ) 2. Test. (Check computed results manually. ) Maintenance Phase 1. Use the program. 2. Maintain. (Modify to meet changed requirements or to correct errors. ) 16