Question: Note: This is C++ Programming. please it has to pass the sanitycheck,( not only compiles). Details This time around, your program will not be so
Note: This is C++ Programming. please it has to pass the sanitycheck,( not only compiles).


Details This time around, your program will not be so chatty. The program will just wait for you to type an integer, and then print a 0 or 1 to indicate whether or not that integer was prime. Here's some sample output of an interactive session (assuming primetest is the name of the executable!): $ ./primetest 11 1 12 After in the response is i, indicating primality; after 12, the response is e, meaning it is not prime. You can end the interactive session by hitting Ctrl-D, or by entering something that is not an integer, like the character a. Important note: your program is not supposed to print any messages! It is just supposed to read from standard input, and write zeros and ones to standard output. The next section will explain why this is a good idea. All right, so let's take a look at a few examples of how someone with a little bit of knowledge about the shell might use your program. To begin, we could use the shell (bash) to print out a list showing which integers are prime: $ echo (1..10) 1 /primetest B. 2 Not so exciting, but notice the use of the pipe | operator, which takes the output of echo and sends it to our program through standard input. So, the cin statements in our code will pick up the output from echo, as if we just sat there typing all the numbers in from the shell. (By the way - the command echo (1..10) by itself will just print the list of integers from i to 10 with spaces in between - try it out.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
