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
agasfer [191]
3 years ago
15

This problem will be discussed in Lab6. In Lab6, the TAs will also discuss about the solution of Function Problem 1 that require

d you to write several functions. Additionally, the last week's lab problems on loop will be discussed too, if you need more help on them. See the deadline. You should try your best to complete it within the lab time. First n prime numbers: Write a program that takes a positive integer n as input and prints all the prime numbers from 1 to n.
Computers and Technology
1 answer:
Stells [14]3 years ago
6 0

Answer:

C++.

Explanation:

#include <iostream>

using namespace std;

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

void printPrime(int n) {

   if (n > 0) {

       cout<<2<<endl;

       

       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<<endl;

       }

   }

   else {

       cout<<"Invalid input";

   }

}

int main() {

   int n;

   cout<<"Enter positive integer: ";

   cin>>n;

   printPrime(n);

   return 0;

}

You might be interested in
A petrol (gas) station is to be set up for fully automated operation. A driver inputs his or her credit card into the pump, the
malfutka [58]

Answer:

Explanation:

Gas Filling Station has pumps. Pumps have credit card readers. Driver can able to swipe their cards, pumps have Fuel. Pumps card readers communicate with Credit Company. Driver interacts with pump for fuel and credit card.

In this situation the following we need to treat as objects.

They are Pump, Card reader, Fuel tank, communication system, system controller and price table.

Design pattern for the following system is attached below

6 0
4 years ago
What software tool can you use to see the applications that are currently running?
Soloha48 [4]

Answer:

You can use the task manager to see what programs are currently running.

Explanation:

7 0
3 years ago
Read 2 more answers
And art for always texting graphics are pasted is known as
Arte-miy333 [17]
<span>A. Mechanical i think sorry if im wrong</span>
6 0
3 years ago
Read 2 more answers
What is the transfer rate of DDR memory?<br> A. 16 bit <br> B. 32 bit <br> C. 64 bit <br> D. 128 bit
marshall27 [118]
C. 64 bit is the answer
3 0
3 years ago
Read 2 more answers
What is the difference between the Paste Special and Paste Link options?
kotegsom [21]
Paste Link lets you automatically update the referenced document.
8 0
4 years ago
Read 2 more answers
Other questions:
  • To keep information beyond reach of unauthorized users, is to keep the information _____. Group of answer choices simple verifia
    7·1 answer
  • What will be the output of “AAAAMMMMMHHHVV” using a file compression technique?
    9·2 answers
  • WHAT SHOULD YOU DO IF AN ONCOMING CAR AT NIGHT APPROACHES WITH ITS HIGH-BEAMS ON?
    6·1 answer
  • Assume that a gallon of paint covers about 350 square feet of wall space. Create an application with a main() method that prompt
    9·1 answer
  • Create a Python program as described below and save it in a file named bool. You should use IDLE or similar environment to creat
    15·1 answer
  • To execute a prepared SQL statement, you can use the ________________ and execute() methods of the PDOStatement object to set pa
    10·1 answer
  • failure of the _ cylinder will often result in sudden unexpected loss of the ability to stop the vehicle
    10·1 answer
  • Njdnkjsdnjvnsdjvnjsdnvjsdvnjdnvjdsnvnksn
    6·1 answer
  • All of the following are examples of service learning opportunities exept
    11·1 answer
  • How many dog breed are there
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!