{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

1 2 request a value for a request a value for b 3 4 5

Info icon This preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: ;B Return A End Finds the Min of 2 numbers This algorithm utilizes: a) Only Sequence a) Sequence and Selection a) Sequence and Iteration b) Sequence, Selection and Iteration What Tool(s) Does this Algorithm Use? 1. 2. 3. 4. 5. 6. 7. Request a value for A Assign 1 to B While A > 1 Assign A*B to B Assign A1 to A Return B End This algorithm utilizes: a) Only Sequence b) Sequence and Selection c) Sequence and Iteration d) Sequence, Selection and Iteration What Tool(s) Does this Algorithm Use? 1. 2. 3. 4. 5. 6. 7. Request a value for A Assign 1 to B While A > 1 Assign A*B to B Assign A1 to A Return B End Computes the factorial of A This algorithm utilizes: a) Only Sequence b) Sequence and Selection a) Sequence and Iteration a) Sequence, Selection and Iteration From Algorithms To Programs So far we have described a few algorithms in pseudocode. Pseudocode is fine for communicating algorithms between people but it is not precise enough to be used by a computer. Our Algorithms Must Be Written in a Programming Language A programming language has precise syntax (grammar) and semantics (meaning). An algorithm in a programming language is called a program. To be used by the machine it must be translated into a native language specific to the computer's CPU (central processing unit) called machine language. This translation is done by a compiler. Writing directly in machine language is taxing for humans because it is so rudimentary. Reading A C++ Program #include <iostream> using namespace std; int main ( ) { double x, y; cin >> x; y = x * 7; cout << y; return 0; } Reading A C++ Program Much of this program is scaffolding. int main ( ) Scaffolding is only { important insomuch as it double x, y; holds the program together cin >> x; and provides context for y = x * 7; the C++ compiler. cout << y; We will consider this part return 0; of the program later. } #include <iostream> using namespace std; Reading A C++ Program The remaining part of the code consists of only 4 lines. The code reads in a number and then writes the result of multiplying the number by...
View Full 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