Submitted by: Submitted by billandmisty78
Views: 449
Words: 289
Pages: 2
Category: Science and Technology
Date Submitted: 05/28/2013 05:07 PM
Week 5 Activity – Numbers Squared
Week 5 Activity – Numbers Squared
-------------------------------------------------
TCO #4 – Given a simple business problem that requires one or more decisions, create a solution algorithm that uses decisions with logical and relational expressions.
-------------------------------------------------
TCO #5– Given a simple business problem that requires iteration, create a solution algorithm that employs loops.
-------------------------------------------------
TCO #9 – Given a program with logic errors that is intended as a solution to a simple business problem, employ debugging diagnostics to remove and correct the errors.
Assignment (part A): Your goal is to solve the following simple programming exercise. Using a FOR loop, write an algorithm that displays the squares of the numbers 1 to 10 to console output. Thought provoking question: Do you need to accept input?
Assignment (part B): Using a pretest WHILE loop, write an algorithm that displays the squares of the numbers 1 to 10 to console output.
No actual input is needed as long as the variable is declared.
IPO Chart:
Input | Processing | Output |
Numbers 1 through 10 | Find square root of each number | Square roots of numbers 1 through 10 |
Part A Pseudocode:
Begin
Declare Real number=1
Declare Real square=0
Display “Discovering the square of number 1 through 10”
FOR number 1 through 10
Set square=number^2
Display “The square of “ + number + “ is “ + square
ENDFOR
Display “End of display”
End
Part A Flowchart:
Part A Example Output after execution:
Part B Pseudocode
Begin
Declare Real number=1
Declare Real square=0
Display “Discovering the square of number 1 through 10”
DO WHILE number <=10
Set square=number^2
Display “The square of “ + number + “ is: “ + square
Set number=number+1
ENDDO
Display “End of display”
End
Part B Flowchart:
Part A...