Download For - La Sierra University

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
CPTG121 Introduction to Computer Science I
La Sierra University
Loop Problems
1. Write a program to input 20 numbers. At the end, it will print out the sum of the numbers.
2. Write a program to input 20 numbers. At the end, it will print out the average of the numbers.
3. Write a program to keep inputting positive integers until a 0 is entered. At the end, it will
print out how many numbers have been entered in.
4. Write a program to keep inputting positive integers until a 0 is entered. At the end, it will
print out the average of the numbers.
5. Input a positive number. Print out the numbers from 1 to the number entered.
6. Input two positive numbers with the second one larger than the first one. Print out the integer
numbers between the two numbers entered inclusive.
7. Input three positive numbers into the three variables start, stop, and step. Stop must be
greater than Start. Print out the numbers between start and stop in increments of step.
8. Input a positive number. Print out that many numbers of stars. E.g. if enter a 6 then print out
6 stars (*).
9. Write a program to input two numbers, and then print out the first 20 numbers of a Fibonacci
Series starting with the two numbers. For example: user entered 1 and 2, program will output
“1, 2, 3, 5, 8, 13, 21, 34, 45, 79… for 20 numbers.”
Page 1 of 1
Copyright Enoch Hwang 2009