CTPS 2017 Discussion Session #3 Flowchart

16
CTPS 2017 Discussion Session #3 Flowchart Page 1: Problem Set Page 2: Solution Set

Transcript of CTPS 2017 Discussion Session #3 Flowchart

CTPS 2017 Discussion Session #3

Flowchart

Page 1: Problem Set

Page 2: Solution Set

Problem Set 1. Draw a flowchart for the given sequence of instructions:

2. Trace the flowchart you have drawn for Q1. 3. Draw a flowchart to tell the user what type of movie they can attend based on their age, if they are with their parents, and their amount of money.

Under 13: G Under 13 w/ parent: G, PG 13 and Over and Under: 16 G, PG Under 16 w/ parent: G, PG, R 16 and Over: G, PG, R Matinee: $7.50 Evening: $10.50

4. Draw a flowchart to generate Fibonacci series uptil N 1,2,3,5,8,13…………….

5. Draw a flowchart to Check whether a number is prime or not.

6. Draw a flowchart to show all prime numbers smaller than or equal to N.

7. Draw a flowchart to Upload a video (user requires an account, video size is restricted).

8. Draw a flowchart for University admission process.

9. Draw a flowchart for Snake and ladder game.

10. Given a flowchart that performs grading, correct it.

11. Draw a flowchart to check if a given number an Amstrong number or not for only 3

digit numbers.

12. Draw a flowchart : A module (function) is given a number i and returns whether it is

prime or not. The name of the module/ function is "IsThisNumberPrime.".

First it checks to make sure the input number is an integer. Then it checks to make sure

the input number is not negative, 0 , or 1. Negative integers, 0, and 1 are not considered

prime by definition.

Next the function tries to divide the input number by i, where i = 2, 3, 4, 5, and so forth,

to see if it divides any of them evenly, that is, without a remainder. If the input number is

divided evenly, it is not a prime. The check stops when i is equal to the input number.

You give the function a number and the output is "Yes" if the number is prime, or "No" if

it is not.

13. Calculate the first 100 prime numbers using the module in Q10.

14. Trace the given flowchart and comment on the use of “ flag”.

15. What does this flowchart perform?

Solution Set

Q1.

Q2.

Q3.

Q4.

Q5.

Q6.

Q7.

Q9.

Q10.

Q11.

Q12.

Q13.

Q14.

FLAG=1 and its never equal to 0... Then further step is not going to execute...[steps

when the value is true] only the value for false condition is going to run which gives

"Print number is prime" all the time......

Q15. Finds the sum of numbers in each set.

https://www.programiz.com/article/flowchart-programming

• http://www.diagramtalk.com/flowchart-diagrams.html

• https://www.lucidchart.com/pages/what-is-a-flowchart-tutorial

• http://creately.com/blog/diagrams/top-10-flowchart-ideas-for-your-small-business/

• http://www4.ncsu.edu/~spbalik/java/IfElseExample.html

• https://www.edrawsoft.com/algorithm-flowchart-examples.php

• http://cquestionsandanswers.blogspot.in/p/flow-charts.html

• http://users.evtek.fi/~jaanah/IntroC/DBeech/3gl_flow.htm