Robotics C++ Physics II AP Physics B Electronics Java Astronomy Other Courses Summer Session  

Exercises

 

Exercise A

 

Write code that will prompt the user for the ages of two individuals.

Use an if statement to determine which is the oldest.

Write the answer, appropriately labeled.

 

Exercise A1

 

Continuation of Exercise A

Write code that will determine when (in how many years) the younger individual will be the same age as tje older one is now

Enter ages such that there is a minimum of 3 years difference in the ages

Print the ages entered, appropriately labeled

Print the answer, appropriately labeled

 

Exercise 1

 

Write code that will sum the integers between 1 and 100 and print the result, appropriately labeled. Use a for loop

 

Exercise 2

 

Write code that will find the sum of and print the even integers between 1 and 50, including the end points, appropriately labeled.

Use a do while loop

Print the numbers 5 per line

When printing the numbers, include a space between each for readability

Exercise 3

A prime number is one that is evenly divisible only by itself and 1. For example, 5 is a prime number. Write code that will find and print all primes between 1 and 100, including the end points

 

Exercise 4

 

Write code that will find and

 

1. Print the sum of the odd integers between 1 and 100, including the end points, apropriately labeled.

2. Print the above odd integers backwards (starting with the largest and ending with the smallest) 5 integers per line, appropriately labeled