Question: Write a program that takes an integer from standard input and prints all prime numbers that are smaller than it to standard output. Recall that

 Write a program that takes an integer from standard input and

Write a program that takes an integer from standard input and prints all prime numbers that are smaller than it to standard output. Recall that a prime number is a natural number greater than 1 whose only positive divisors are 1 and itself. At the start of the program, prompt the user to input a number by printing "Input a number greater than 2: ". If the user's input is less than or equal to 2, then print "No prime number is smaller than . ", where is replaced by the number input by the user. If the user inputs a number greater than 2, then print "Prime numbers smaller than : ". Then, on the same line, print out a list of all prime numbers that are smaller than the input. In your list, each prime number must be separated by one space and a newline must be printed immediately after the last number in the list. As part of your program, you must make a function that takes an integer as an argument, returns 1 if the integer is prime, and returns 0 otherwise. You can use the following function prototype: int isPrime(int number); Example input/output pairs (excluding the prompt) are provided below: Input: 6; Output: Prime numbers smaller than 6: 2 3 5 Input: 23; Output: Prime numbers smaller than 23: 2 3 5 7 11 13 17 19 Input: 1; Output: No prime number is smaller than 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!