Chapter 6 and 7 - Tutorial 1
Loop Practice Questions
Compound Interest Calculator Question
Ahmad deposits RM 1000 in a bank with 5% annual interest. Write a program using a for loop to show his balance after each year for 4 years. Use the formula: New Balance = Previous Balance × 1.05
Pyramid Builder Question
Write a program using nested for loops to create a number pyramid pattern where each row shows repeated numbers. The number of row is the same as the input. So if user enter 4, the number of row will be 4.
Expected Output:
1
22
333
4444Factorial Calculator Question
Write a program using a for loop to calculate the factorial of any positive integer.
Prime Number Checker Question
Write a program that asks the user to input a number, then uses a loop to check if that number is prime.