Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2: The following pseudocode and flowchart have been designed to get an integer number from the user and print if it is a perfect

Problem 2: The following pseudocode and flowchart have been designed to get an integer number from the user and print if it is a perfect number or not.

Note: a perfect number is a positive integer which is equal to the sum of its proper divisors, excluding itself. For example 6 and 28 are perfect numbers because 6 = 1+2+3 and 28=1,2,4,7,14.

1: Start

2: num = 0

3: sum = 1

4: divider = 2

5: Read (num)

6: While ((num / 2) >= divider) DO

7: IF (num % divider == 0) Then

8: sum=sum+ divider

9: End IF

10: divider = divider + 1

11: End While

12: IF (num == sum AND num != 1) Then

13: Print (num , is a perfect number.)

14: Else

15: Print (num , is not a perfect number.)

16: End IF

17: End

image text in transcribed

i. Using a trace table (one per input), trace the algorithm for the following values and show the output. See the end of document for an example trace table using input 7. 25, 1, 0, 6, 28

ii. Modify the psuedocode or the flowchart in order to print out all the perfect numbers between a range of values given by the user, for example between 1 and 1000, or 200 and 800, etc

image text in transcribed

Trace Table: How to make a trace table for Part A, Problem 2 i) with 7 as a user input. (Note: Lab 0 also contains another example of a trace table for a different problem)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Heikki Topi, Jeffrey A Hoffer, Ramesh Venkataraman

13th Edition

0134773659, 978-0134773650

More Books

Students also viewed these Databases questions

Question

Define Administration and Management

Answered: 1 week ago

Question

Define organisational structure

Answered: 1 week ago

Question

Define line and staff authority

Answered: 1 week ago

Question

Define the process of communication

Answered: 1 week ago

Question

Explain the importance of effective communication

Answered: 1 week ago

Question

=+g. Does it deliver one, instantly understandable message?

Answered: 1 week ago

Question

=+e. Does it entertain, inform and/or engage the reader?

Answered: 1 week ago

Question

=+h. Do all of the related materials project one cohesive message?

Answered: 1 week ago