Lesson 02 -Tutorial
Lesson 02 -Tutorial
Problem: Write an algorithm and draw a flowchart to create a simple calculator that
can perform addition, subtraction, multiplication, and division of two numbers.
Instructions:
Instructions:
1. Input a number.
2. Check if the number is divisible by 2.
3. If divisible, print "Even".
4. If not divisible, print "Odd".
Problem: Write an algorithm and draw a flowchart to find the largest of three
numbers.
Instructions:
Instructions:
1. Input a number.
2. Initialize a variable to store the factorial result.
3. Use a loop to multiply the numbers from 1 to the given number.
4. Print the factorial result.
Instructions:
1. Input a number.
2. Check if the number is divisible by any number other than 1 and itself.
3. If divisible, print "Not Prime".
4. If not divisible, print "Prime".
Problem: Write an algorithm and draw a flowchart to calculate the sum of the first N
natural numbers.
Instructions:
1. Input a number N.
2. Initialize a variable to store the sum.
3. Use a loop to add numbers from 1 to N.
4. Print the sum.
1. Input a number.
2. Use a loop to reverse the digits of the number.
3. Print the reversed number.
Problem: Write an algorithm and draw a flowchart to generate the first N terms of
the Fibonacci series.
Instructions:
1. Input a number N.
2. Initialize the first two terms of the series (0 and 1).
3. Use a loop to generate the next terms by summing the previous two terms.
4. Print the series.
Instructions:
1. Input a string.
2. Reverse the string.
3. Compare the original string with the reversed string.
4. If they match, print "Palindrome".
5. If they don't match, print "Not Palindrome".
Instructions:
Instructions:
Problem: Write an algorithm and draw a flowchart to check if a given year is a leap
year.
Instructions:
1. Input a year.
2. Check if the year is divisible by 4 but not by 100, or if it is divisible by 400.
3. If it meets the conditions, print "Leap Year".
4. Otherwise, print "Not a Leap Year".
Instructions:
1. Input a string.
2. Initialize a counter for vowels.
3. Check each character in the string to see if it is a vowel (a, e, i, o, u).
4. Increment the counter for each vowel found.
5. Print the total count of vowels.
Problem: Write an algorithm and draw a flowchart to find the second largest
number in a list of numbers.
Instructions:
Instructions:
1. Input a password.
2. Check if the password meets the length requirement.
3. Check if the password contains at least one uppercase letter, one lowercase
letter, and one digit.
4. If all conditions are met, print "Valid Password".
5. Otherwise, print "Invalid Password".