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

Info icon This 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
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
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
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
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
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
Image of page 6
P : Computing Max Perm for an integer P : MaxPerm(n) Q : Perm_with_Largest_Digit_at_MSI(n) 7
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
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
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 ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern