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
Kisachek [45]
3 years ago
12

You will complete 3 tasks. Task 1: Determine if the input number is prime or not You will ask the user for an integer You will d

etermine if the integer is prime or not and print out that information for the user Task 2: Determine the greatest common factor of 2 numbers You will ask the user for 2 integers You will determine what the greatest common factor of the two numbers is and print that information for the user Task 3:Determine the least common multiple of 2 numbers You will ask the user for 2 integers You will determine the least common multiple of the two numbers and print that information out for the user Ex: If the input is:
Computers and Technology
1 answer:
GuDViN [60]3 years ago
6 0

Answer:

Program is written in C++

#include<iostream>

using namespace std;

int main()

{

//1. Prime Number

int num;

cout<<"Input Number: ";

cin>>num;

int chk = 0;

for(int i =2; i <num;i++)

{

 if(num%i==0)

 {

  chk = 1;

  break;

 }

}

if(chk == 0)

{

 cout<<num<<" is prime"<<endl;

}

else

{

 cout<<num<<" is not prime"<<endl;

}

//2. Greatest Common Factor

int num1, num2, x, y, temp, gcf;  

cout<<"Enter two numbers: ";

cin>>num1;

cin>>num2;

x = num1;

y = num2;

while (y != 0) {

   temp = y;

   y = x % y;

   x = temp;

 }

 gcf = x;

 cout<<"Greatest Common Factor: "<<gcf<<endl;

 

// 3. LCM  

cout<<"Enter two numbers: ";

cin>>num1;

cin>>num2;

x = num1;

y = num2;

while (y != 0) {

   temp = y;

   y = x % y;

   x = temp;

 }

 gcf = x;

 int lcm =(num1 * num2)/gcf;

cout<<"Least Common Multiple: "<<lcm<<endl;

return 0;

}

Explanation:

<em>I've added the full source code as an attachment where I make use of comments to explain some lines</em>

Download cpp
You might be interested in
Based on the following pseudo-codes, if the value of num1 is 6 and the value of num2 is 8, then which of the following is the fi
yuradex [85]
Do any of u have an answer


3 0
4 years ago
Yuri, a medical assistant, has been asked to send an account of a patient's last office visit to another doctor's office. The te
g100num [7]
The internet,,

To let the other doctor know about specific details on the patient, and other excessive information.

Hope this helps!! :)
6 0
3 years ago
Read 2 more answers
What would the output be if we replaced the math expression in the last line with dependents * ((yearsOnJob - 1) * 4) - 6 and th
Leona [35]

Answer:

Please check the explanation.

Explanation:

Let x=dependents * ((yearsOnJob - 1) * 4) - 6

where dependents=3

Lets supppose year on job 3

then

x=( 3*((3-1)*4)-6

x= 3*8 -6

= 24-6

=18

And similarly, we can calculate the value of arithmetic expression all the time.

5 0
3 years ago
Which is the following should be selected in the paragraph dialogue box to prevent page break from occurring within a paragraph
Savatey [412]

Answer:

Explanation: keep lines together

6 0
3 years ago
Which tab is used to edit objects on the Slide Master and layouts?
andreev551 [17]
When your trying to master the slide layouts you must go to the Slide Layout tab.
4 0
3 years ago
Other questions:
  • In the 1960s, techniques were developed that allowed individuals to fool the phone system into providing free access to long dis
    14·1 answer
  • If a security officer is non-commissioned officer, he can carry a baton on duty if he went through a training class
    8·1 answer
  • Nicole wants to create a database to collect information about videos in her video rental store. She would like to use the datab
    9·1 answer
  • Naseer has inserted an image into his document but needs the image to appear on its own line.
    14·2 answers
  • On a pie chart, the different sections or "wedges" show:
    9·1 answer
  • What argument for "the seen" suggested that breaking windows is a good thing?
    11·1 answer
  • "Most of us know that when we come into a college classroom, we will see desks and chairs, a computer station and a projector. A
    6·1 answer
  • Which of the following types does the Java programming language support?
    9·2 answers
  • 9.2 code practice edhesive
    14·1 answer
  • What do you use the Pygame library for?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!