List the integers from 1 to n. You already know that 1 is prime. Starting with 2, cross out every number that's a multiple of 2. (Do not cross out 2; only cross out multiples beyond the number you're working on.) Move on to 3, and so forth: each time you come to a number that isn't crossed out, cross out all of its multiples. When there are no more numbers to be crossed out, the remaining numbers in the list are all the primes between 1 and n.
(There was an example use of this algorithm on the printed copy of this assignment, but I don't think I can html-ize it very easily. See me if you have questions.)
A design document is required for this assignment. Remember to turn in your printed source code and output, and an electronic copy of your program.
Since there's going to be more than one screenful of output all at once, the easiest way to get the output is to capture it in a file. In order to do this, you need to run your program from the command line (not directly from the compiler, nor by double-clicking on the .exe). When you run it, do so by typing (for example) "hw6 > output.txt". This creates the file "output.txt" in the same directory as your executable.
The following is what I captured from the MS-DOS prompt window when I did this:
C:\WINDOWS>cd desktop C:\WINDOWS\Desktop>cd work C:\WINDOWS\Desktop\Work>cd hw6 C:\WINDOWS\Desktop\Work\hw6>cd debug C:\WINDOWS\Desktop\Work\hw6\Debug>hw6 > output.txt C:\WINDOWS\Desktop\Work\hw6\Debug>
The dot product of two vectors, Va = {a1, a2, ..., an} and Vb = {b1, b2, ..., bn} is
Va · Vb = a1 * b1 + a2 * b2 + ... + an * bnThe dot product is only defined for two vectors of the same length; however, if you have two vectors of different length, the short one may be padded with zeros to the length of the longer one.
Your function should accept arrays of any size, remembering the definition of the dot product, but the main program may accept only one size of array.
You can consolidate the two parts of your assignment (i.e., write one program that asks whether you'd like to find primes or calculate a dot product) if you'd like, but you don't have to.