1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Aliun [14]
3 years ago
14

Create a function named test2Problem2that contains a list comprehension. This function will take asingle integer parameter nand

returns a list of length n of every other prime. (Please note that primes start at 2.)There will be a 10 point deduction for not using a list comprehension to solve this problem.List comprehensions have this form: [ expression for item in list if conditional ]In:10Out:[2,5,11,17,23,31,41,47,59,67]In:7Out:[2,5,11,17,23,31,41]
Computers and Technology
1 answer:
ikadub [295]3 years ago
3 0

Answer:

C++.

Explanation:

#include <iostream>

using namespace std;

/////////////////////////////////////////////////////////

void printPrime(int n) {

   if (n > 0) {

       cout<<"[2";

       for (int i=3; i<=n; i++) {

           bool isPrime = true;

           

           for (int j=2; j<i; j++) {

               if (i % j == 0) {

                   isPrime = false;

                   break;

               }

           }

           

           if (isPrime == true)

               cout<<", "<<i;

       }

   }

   else {

       cout<<"Invalid input";

   }

   cout<<"]";

}

/////////////////////////////////////////////////////////

int main() {

   int n;

   cout<<"Enter positive integer: ";

   cin>>n;

   printPrime(n);

   return 0;

}

You might be interested in
Named constants should be used when they serve to improve readability and understanding. T or F
prisoha [69]
The answer is true.

Let's say we are calculating the volume of a grain silo where the the width is a constant, but the height can be changed.

In our code we would calculate the volume using something like:

PI * (WIDTH / 2)^2 * height

The variables in all caps would be named constants. Using them makes the code more readable to other people than if we were to just use their values like:

3.14 * (145.75 / 2)^2 * height




8 0
3 years ago
Read 2 more answers
Which of the following is not possible? A class that implements two interfaces. A class that inherits from two classes. A class
ozzi

Answer:

"A class that inherits from two classes"

Explanation:

If we're talking about Java, you can't extend from two classes. The reason for this is Java doesn't allow multiple inheritance.

The reason for this is to avoid the ambiguity caused by it. One of the cases where multiple inheritance can cause ambiguity is the diamond problem.

Diamond problem can occur if two classes (say B and C) inherit from one class (say A). And another class (say D) inherits from both B & C.

If B and C class override the same method from A class. And D class calls that method, which one will be called, class B's or C's??

4 0
3 years ago
Problem 1. MST - Prim's and Kruskal's algorithms
Juli2301 [7.4K]
Or maybe not Encryption converts the data in a database to a format that is indecipherable to unauthorized users who attempt to bypass the DBMS.

a. True
b. False
7 0
3 years ago
Which of the follow is an example of an integer?<br> "1.091"<br> "number"<br> 15<br> name
UkoKoshka [18]

Answer:

The answer is 15

Explanation:

A integer is a whole number, the only wholenumber present is 15

Hope this helps :)

8 0
2 years ago
What's it called when a program is expandable?
sashaice [31]
Its called a genesis program
6 0
3 years ago
Other questions:
  • True or false An electronic form uses input fields in which the user can enter data from their own computer and then transmit t
    10·1 answer
  • Question 1 of 40
    12·1 answer
  • Troubleshooting a printer that does not work includes a. connecting the printer to your computer b. checking to see if there is
    13·1 answer
  • A(n) _______________ is a collection of configuration and security settings that an administrator has created in order to apply
    14·1 answer
  • Amy just added a 462 meter run of fiber optic cable to the network what should she do next?
    10·1 answer
  • Where in an email would u find information about the action requirements​
    9·1 answer
  • In implementing Secunity Lfe Cycle:_______
    8·1 answer
  • DEF is a small consulting firm with ten on-site employees and 10 to 12 part-time (off-site) software consultants. Currently, the
    5·1 answer
  • Kylee needs to ensure that if a particular client sends her an email while she is on vacation, the email is forwarded to a
    5·1 answer
  • Which external reference is formatted correctly?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!