Lecture2a- Algorithm.pdf Flashcards
What is the main purpose of writing a program?
To solve a problem by designing, implementing, and testing a solution.
What are the key steps in solving a problem through programming?
Understand the problem
Design a solution
Consider alternatives and refine the solution
Implement the solution
Test the solution
Why is breaking a solution into smaller pieces important?
It makes the solution manageable and allows for better organization, especially using object-oriented programming.
What are the four basic software development activities?
Establishing requirements (What the program must do)
Creating a design (How the program will work)
Implementing the design (Writing source code)
Testing (Ensuring the program works correctly)
What is an algorithm?
A step-by-step set of instructions to solve a problem, acting as a blueprint for writing a program.
What are the steps (psuedocode) to calculate the area of a circle?
Get the radius.
Compute the area using the formula A = π × r × r.
Display the result.
What is pseudocode?
A mix of natural language and programming concepts used to outline a solution before coding.
What is a flowchart?
A diagram that represents an algorithm using symbols (e.g., rectangles for processes, diamonds for decisions).
Describe the psuedocode for converting Celsius to Fahrenheit?
Declare variables: TempCelsius, TempFahrenheit.
Prompt the user for a Celsius input.
Store the user input in TempCelsius.
Calculate TempFahrenheit = (TempCelsius × 9/5) + 32.
Display the Fahrenheit value.