{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lec17+18 - ESc101 Fundamental of Computing I Semester...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
ESc101 : Fundamental of Computing I Semester 2008-09 Lecture 17+18 Structured programming using methods Common Steps in Solving a problem 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Syntax of a method return type method name ( input ) { Body } if there is no input parameter, we leave the parenthesis blank. 2
Background image of page 2
Methods offer a structured (top-down) way of writing the programs To solve a problem, divide it into smaller subproblem. Divide each smaller sub-problem into further smaller sub-sub-problems until they become easy to solve (code should be 10-20 lines). finally for each problem, sub-problems,sub-sub-problems, write a separate method. 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Advantages of structured programming It is an easier way to design solution of the problem. It is easy to code since each method will be a small piece of code. The program becomes more manageable . It reduces the chances of logical errors . 4
Background image of page 4
Two Examples of Structured Programming Printing a Diamond with a given half-width Computing the Maximum value permutation for an integer 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
P : Computing Max Perm for an integer P : MaxPerm(n) 6
Background image of page 6
P : Computing Max Perm for an integer P : MaxPerm(n) Q : Perm_with_Largest_Digit_at_MSI(n) 7
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
P : Computing Max Perm for an integer P : MaxPerm(n) Q : Perm_with_Largest_Digit_at_MSI(n) Num_of_Digits(m) Power_of_Ten(i) Max_Digit_Index(n,digits) Value_of_Digit_at_Index(n,index) 8
Background image of page 8
P : Computing Max Perm for an integer P : MaxPerm(n) Q : Perm_with_Largest_Digit_at_MSI(n) Num_of_Digits(m) Power_of_Ten(i) Max_Digit_Index(n,digits) Value_of_Digit_at_Index(n,index) 9
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}