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
Analyze the following code. II: public class Test { public static void main(String[] args) { System.out.println("Welcome to Java
Grace [21]

COMPLETE QUESTION

I. public class Test {

public static void main(String[] args){

System.out.println("Welcome to Java!");

}

}

II. public class Test { public static void main(String[] args) {System.out.println("Welcome to Java!");}}

Answer:

Both codes will compile and run and display Welcome to Java, but the code in II has a better style than I

Explanation:

When written codes, paying attention to proper coding styles and efficient memory management enables us to create programs that are highly efficient, coding styles refer to proper indentions and avoiding too lenghty lines of code (as is in code I), adding approprite comments etc.

8 0
3 years ago
Which input value causes the loop body to execute a 2nd time, thus outputting "In loop" again? { String s = "Go"; while ((!s.equ
Ksenya-84 [330]

Answer:

a) "Quit"  

c) "Q only

Explanation:

Given

<em>String s = "Go"; </em>

<em>while ((!s.equals("q"))&& (!s.equals("")))  {</em>

<em>System.out.println("In loop"); </em>

<em>s = scnr.next();</em>

<em>}</em>

<em />

Required

What input causes another execution

Analyzing the while condition

<em>while ((!s.equals("q"))&& (!s.equals("")))  </em>

<em />

This can be split into:

<em>!s.equals("q")) && (!s.equals(""))</em>

<em />

Meaning

When s is not equal to "q" and when s is not an empty string

<em />

In other words,

the loop will be executed when user input is not "q" and user input is not empty.

So, from the list of given options: The loop both will be executed when:

a) Input is "Quit"

c) Input is Q only

<em>Input of q will terminate the loop, hence b and d are incorrect</em>

<em />

6 0
3 years ago
Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes rece
nydimaria [60]

Answer:

The following fix were made to the program

  1. Change void main() to int main(), then set a return value at the end of the main function;  e.g. return 0
  2. Remove system("pause");  It's not needed
  3. For each of the array, change their lengths to 5 i.e. int votes[5];  string name[5];   and float percent[5];
  4. Lastly, calculate the percentage using: percent[i]=((votes[i]*100.0/total))

Explanation:

(1) void main implies that the main function will not return any value. So, you change it to int main() and then set the return value

(2) There is no need to pause the program, so system.("pause") is not necessary.

(3) The question says there are 5 candidates. So, we set the arrays to accommodate inputs for 5 values

(4) percent array is declared as float; 100.0 will ensure that it calculates the percentage as a float value.

<em>See attachment for updated code</em>

Download cpp
3 0
3 years ago
When starting a computer running Windows Vista, a technician sees that the error message "BOOTMGR is missing" appears after the
docker41 [41]

Answer:

B and C

Explanation:

Possible solution to solving "BOOTMGR is missing" error in Windows Vista is to use the Windows Recovery Environment.

Another option is to run "bootrec/fixboot" command from the comman prompt and the command prompt is also accessible from the windows recovery environment.

8 0
3 years ago
Jerry is entering information from the documents that show what customers bought and what they owe. What document is he working
il63 [147K]
The answer would be C. Invoice
4 0
3 years ago
Read 2 more answers
Other questions:
  • Crowdsourcing is:
    5·1 answer
  • A group of eight bits is called a _______. a. numeric data b. byte c. megabit d. binary
    5·1 answer
  • What does it mean to design,<br> implement, and maintain computer<br> systems?
    15·1 answer
  • Plz answer me will mark as brainliest ​
    8·1 answer
  • What is the best prediction she could make about this
    15·2 answers
  • Compter History Large Resume Include: the beginnings of the computer and its development during the years The events of computer
    10·1 answer
  • Which of the following are the functions of an os?
    8·1 answer
  • When creating envelopes, how will you adjust the layout?
    10·2 answers
  • Which Boolean operator enables you to exclude a search term?
    11·1 answer
  • A presentation software that is used to organize and present pertinent information using graphics, word processing, outlining, d
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!