Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***C++*** Descriptiorn Write a function that takes a positive integer and displays all the prime numbers of smaller than or equal to the given integer.

***C++*** image text in transcribed
Descriptiorn Write a function that takes a positive integer and displays all the prime numbers of smaller than or equal to the given integer. Add this function as another option to your main program. Display purpose of the program. Get number -takes no argument and returns an integer inputted by the user. Integer must be larger than 1 but smaller than 10000. Is prime- takes an integer as its argument and returns a Boolean variable, which indicates if the given integer is prime or not. To determine if the integer (number) is prime write a loop that checks if given number is divisible (use % operation) by any integer from 2 to number 1 If given number is not divisible by any of those integers then it is prime, otherwise it is not Use is prime function to check all the numbers fro 2 to inputted number and display those that are prime

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions