Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following question is for Advanced Object-Oriented. Please do the following question as instructed by the information. Keep it as simple as possible. The following

The following question is for Advanced Object-Oriented. Please do the following question as instructed by the information. Keep it as simple as possible.

The following instructions for this program:

A function to check whether a value is a prime number:

bool isPrime(int value)

Another function to print first n prime numbers in several lines, each of which contains m numbers. The default value of m is 10 is not provided when the function is called.

void displayPrimeNumbers(int n, int m)

Call the display function in the main function to display first 100 numbers in 5 lines.

Call the display function in the main function to display first 40 prime numbers without providing the value of m.

==========================================================================

The following code is what I have, please use this a base and keep it simple, no need for advance codes. This is all done in Visual Studio 2022 C++. Remember to use functions provided above in the program.

// PrimeExercise_23SP.cpp : This file contains the 'main' function. Program execution begins and ends there. //

#include using namespace std;

int main() {

int testValue = 2; int count = 0; int currentLine = 1; //loop structure to get 50 prime numbers while (count < 50) { //to get a prime bool isPrime = true;

//Check the divisors of a value for (int possibleDivisor = 2; possibleDivisor < testValue; possibleDivisor++) { if (testValue % possibleDivisor == 0) { isPrime = false; break; } }

//print it out if (isPrime) { cout << testValue << " "; count++; if(count%10==0) { cout << endl; //currentLine = 1; } } testValue++; //to start a new line once there are 10 numbers in the current line }

return 0; }

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu // Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: // 1. Use the Solution Explorer window to add/manage files // 2. Use the Team Explorer window to connect to source control // 3. Use the Output window to see build output and other messages // 4. Use the Error List window to view errors // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file

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_2

Step: 3

blur-text-image_3

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

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions

Question

a. How do you think these stereotypes developed?

Answered: 1 week ago

Question

7. Describe phases of multicultural identity development.

Answered: 1 week ago