Sample Questions - For Loops (6 days)

 

 

1. Write a program that will print out pattern

    2 4 6 8 10 12 ->20

 

2. Write a program that will print out pattern

   100 95 90 85 -> 5

 

3. Write a program that will let you enter 2 numbers and will then print out all the numbers between the 2 numbers.

 

4. Write a program that will let find the sum of the numbers between 1 and 100.

 

5. Write a program that will let you enter a number and will then print out the sum of the numbers between 1 and that number.

 

6. Write a program that will print out all the numbers between 1 and 1000 that 7 or 5 go into evenly.

 

7. Write a program that will print out the sum for all the numbers between 1 and 1000 that 7 and 5 go into evenly.

 

8. Write a program that will let you enter a number and will then print out first 50 multiples for that number.

 

9. Write a program that will let you enter 50 numbers and will then print out the sum and the average for those numbers.

 

10. Write a program that will find the sum for 1/2 + 1/3 + 1/4 ... 1/100

 

11. In 1626 the Dutch bought Manhattan for $24. How much would they have today if they invested it at 4% compounding interest.

 

12. Write a program that will find the sum of the odd numbers between 1 and 100.

 

13. Write a program that will let you enter 2 numbers and will then print out the GCF for those numbers.

 

14. Write a program that will let you enter 2 numbers and will then print out the LCM for those numbers.

 

15. Write a program that will let you enter a number and will then print out he factors for that number.

 

16. Write a program that will tell you how much money you will have after 20 years if you start with 2000 and get 5% interest a year and withdraw 120 a year.

 

17. Write a program that will let you enter your name and then enter a number and will then print out the name that many times.

 

18. Write a program that will let you enter 20 numbers and will then print out the biggest and smallest numbers that were entered.

 

19. Write a program that will let you enter a base, then enter an exponent and will print out that number raised to that power.

 

20. Write a program that will let you enter a number and will then print out the factorial for that number. 

Ex. 

 Enter a number 5

Factorial is 120

(because 5 * 4 * 3 * 2 * 1 = 120)

21. Write a program that will let you enter 2 numbers and will give you the sum of the numbers between the 2 numbers, inclusively (including the 2 numbers themselves).

22. Enter a number and have the computer tell you whether it is prime or composite.

23. Enter 10 numbers and print out how many were odd and print out the average of the odd numbers.

24. Write a program that will give you the sum of the numbers :
7 + 14 + 21 + 28 + 35 ... under 1000

25. Enter 100 numbers. Print out the sum of the odd numbers that were entered.

26. Rabbits double every month. If you start with 2, how many will you have after 5 years?

27. Write a program that will let you enter a number, and will then let you enter that many numbers and will then give you the average of the numbers you entered, For example, if you entered a 5, the computer would then let you enter 5 numbers and then give you the average of those 5 numbers.