Think through how you might sum n numbers. One way to solve
this is with a loop. Write a program that takes a value n from the user
and adds up the numbers from 1 to n inclusive. You program should use
four different loops: for loop with increment, for loop with decrement,
while loop with increment, while loop with decrement. Then print the
output value of each loop to the screen.
Make a script (call it lab03_loop.script) testing your program for at least n = 100 (more testing would be better, see section 3.4 of out book). Be sure to filter the script and directed at the bottom of the script page.
Upload your source code (lab03_loop.cpp) and your script
(lab03_loop.script) to the CSHomework
system. Turn in a hard copy of your source code.
Think through how you might check for primes. One way to solve
this is with a doubly-nested loop. The outer look will iterate from 2
to n, while the inner loop checks to see if the current integer is
prime by checking for divisors. You may use the template provided to
help you organize your program.
Make a script (you could call it lab03.script) testing your program for n = 100. Be sure to filter the script and directed at the bottom of the script page.
Upload your source code (lab03.cpp) and your script
(lab03.script) to the CSHomework
system.
Hand in a print-out of your source code (lab03.cpp).