lec17+18

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

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

ESc101 : Fundamental of Computing I Semester 2008-09 Lecture 17+18 Structured programming using methods Common Steps in Solving a problem 1

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

View Full Document
Syntax of a method return type method name ( input ) { Body } if there is no input parameter, we leave the parenthesis blank. 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

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

View Full Document
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
Two Examples of Structured Programming Printing a Diamond with a given half-width Computing the Maximum value permutation for an integer 5

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

View Full Document
P : Computing Max Perm for an integer P : MaxPerm(n) 6
P : Computing Max Perm for an integer P : MaxPerm(n) Q : Perm_with_Largest_Digit_at_MSI(n) 7

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

View Full Document
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
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

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern