Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop an algorithm and a C program that asks the user to enter an integer greater than 1 and then lists all the prime numbers

Develop an algorithm and a C program that asks the user to enter an integer greater than 1 and then lists all the prime numbers between 1 and the user's input. Note: 1 is not a prime number. Remember: a prime number is evenly divisible by 1 and itself only. Note 1: the % operator might be very useful. Note 2: you can end a loop early by using the break statement (which is a keyword in C)... this may be useful.

Here are some additional requirements:

employ a programmer-created function (PCF) named greet( ) that will communicate the purpose of the program to the user

greet( ) shall be called from main( )

employ a programmer-created function (PCF) named get_input( ) that will obtain an integer from the user... get_input( ) will test the user's input to make sure the input is greater than 1... if the user's input is not greater than 1, get_input( ) will communicate an error message to the user and then ask the user to enter another integer

get_input( ) shall be called from main( )

get_input( ) shall employ a while loop as part of its error checking and asking the user to enter another integer

Note: do not try to determine if the user's input is an integer... only concern yourself with determining if the user's input is greater than 1

employ a programmer-created function (PCF) named list_primes( ) that will display all the prime numbers between 1 and the user's input (do not list 1 because it isn't a prime number)

list_primes( ) shall be called from main( )

list_primes( ) shall employ a while loop

PLEASE HAVE A GOOD ALGORITHM FOR THIS CODE

PLEASE USE PUTTY OR FANG

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions