L1F24BSSE0145
L1F24BSSE0145
Lab 05
Topic Flowgorithm
Flowgorithm
Iterative Solutions
o Loops
Objective
For
While
Do-while
Looping using While
Looping using For
Factorial of a number
Lab task
Task1: Distance Calculator
Input Validation: Do not accept a negative number for speed and do not accept any value
less than 1 for time traveled.
Task 2: Positive and Negative Number Counter
Draw a flowchart that asks the user to enter numbers as many as he wants till he presses
the magic number 123. Count all the numbers that are positive, zero, and negative.
Sample Output:
Enter Number: 12
Enter Again: 122
Enter Again: -33
Enter Again: 67
Enter Again: -34
Enter Again: 0
Enter Again: -5
Enter Again: 0
Enter Again: 123
Results:
Positive Count: 3
Zero Count: 2
Negative Count: 3
Task 3: Sum of all Digits
Draw a flowchart that asks a user to enter a decimal number and then display the sum of all
digits present in that number
Sample Output:
In an application, the user has to enter his/her valid passcode. A valid passcode must
contain less than 5 digits at most 4 digits, also 0 digit must not be part of the number
entered. Draw a flowchart that can check whether the entered passcode is valid or not by
counting the total number of digits entered and display it.
Sample Input:
Enter your passcode (should be non-zero and less than 5): 551
Sample Output:
Passcode is invalid! Digit Count: 3! Enter again: 5512
Passcode Valid
Task 5: Fibonacci Series
The number or arrangement of petals on a flower are in such a way that each number adds
the previous consecutive number to find the next number in the series. This series is
Fibonacci series. Write a program that takes the number of terms in this series and print it.
Sample Input:
Sample Output:
Task 6: Salary Calculator
Draw a flowchart that calculates how much a person would earn over some time if his or her
salary is 1000 the first day and 2000 the second day and continues to double each day. The
program should ask the user for the first day's salary and total number of days. Display a
table showing how much the salary was for each day, and then show the total pay at the
end of the period. The output should be displayed in the total amount.
Input Validation: Do not accept a number less than 1 for the salary of the first day and the
number of days worked.
Sample Output:
Enter the salary for the first day: 1000
Enter the number of days: 5
You are creating a fitness tracker that tracks how many steps a user takes each day. The
system should:
1. Prompt the user to input their step goal for the day.
2. Continuously ask the user to input the number of steps they have taken.
3. Stop when the user’s total steps for the day reach or exceed the goal.
4. Display a message congratulating the user once the goal is reached.
Example 2:
Input: 0
Output:
Sum = 0
Average = 0
Maximum = 0
Minimum = 0
Home Task
Task 8: Odds and Squares
Draw a flowchart that uses while loops to perform the following steps: