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
vivado [14]
4 years ago
6

Write an algorithm and draw a flowchart to input two numbers from the user and display the largest of two numbers

Computers and Technology
1 answer:
Ann [662]4 years ago
4 0

Answer:

Explanation:

Required

- Algorithm to display largest of two numbers

- Flowchart to display largest of two numbers

Algorithm

1. Start  

2. Input num1, num2

3. Largest = num2

4. If num1 > num2 Then

4.1 Largest = num1  

4. Print Largest

5. Stop.

<em>See attachment for flowchart</em>

To do this, three variables (num1, num2 and Largest) are used.

The algorithm starts by inputting values for num1 and num2; Then variable Largest is initialized to num2

If num1 is greater than num2, the value of Largest is changed to num2; else, nothing changes

Then Largest is printed.

You might be interested in
When does the following while-loop stop running?
8090 [49]

The loop never stops running because the value of var is always 1.

5 0
3 years ago
A small _____ at the lower right corner of a tool indicates that it contains hidden tools​
Vinil7 [7]

Answer:

A small <u><em>TRIANGLE</em></u> at the lower right corner of a tool indicates that it contains hidden tools​

Explanation:

hope it helps you :)

6 0
2 years ago
A prime number is an integer greater than 1 that is evenly divisible by only 1 and itself. For example, the number 5 is prime be
Gemiola [76]

Answer:

The c++ program to check prime numbers is shown below.

#include <iostream>

using namespace std;

bool isPrime(int n);

bool isPrime(int n)

{

   bool prime;

   int p=0;

   

   if(n==2 || n==3)

       prime = true;

   else if(n%2 == 0)

       prime = false;

   else

   {

       for(int k=3; k<n/2; k++)

       {

           if(n%k == 0)

               p++;

       }

   

   if(p>1)

       prime = false;

   else

       prime = true;

   }

   

   return prime;

}

int main() {

   int num;

   do

   {

       cout<<"Enter a positive number."<<endl;

       cin>>num;

       if(num<1)

       {

           cout<<"Invalid number. Enter a positive number"<<endl;

           cin>>num;

       }

   }while(num<2);

   

   cout<<"The "<<num<<" is prime. "<<isPrime(num)<<endl;

   

   

}

 

OUTPUT

Enter a positive number.

-4

Invalid number. Enter a positive number

0

Enter a positive number.

101

The 101 is prime. 1

Explanation:

The user input is validated for positivity. A do while loop along with if statement is implemented for verification.

do

   {

       cout<<"Enter a positive number."<<endl;

       cin>>num;

       if(num<1)

       {

           cout<<"Invalid number. Enter a positive number"<<endl;

           cin>>num;

       }

   }while(num<1);

The test for prime number is done by using multiple if else statements and a Boolean variable prime is used.

If user inputs 2 or 3, variable prime is set to true.

Else If user inputs an even number, variable prime is set to false. This is done by taking modulo of the number upon division by 2.

Else if user inputs neither an even number nor a number less than 3, the modulus of the number is taken with divisors beginning from 3 up to half of the input number. Here, an integer variable p is used and based on its value, variable prime is set to true or false.

For this, an integer variable p is initialized to 0. A number can be completely divisible by itself or by its factors.

If the number is divisible by any of the divisors, value of variable p is increased by 1. If value of p is greater than 1, this means that the user input is divisible by more than one divisor. Hence, the given number is not a prime number and the variable prime is set to false. Otherwise prime will be set to true.

The value 1 indicates true and 0 indicates false.

4 0
3 years ago
How to make a negative number positive in excel
Viefleur [7K]

Answer:

DB * -1

Explanation:

Use this formula: DB * -1

DB = Desired Box

DB * -1

4 0
3 years ago
Which steps will create a new blank word document
mrs_skeptik [129]

Answer:

Open word

File > New

Select a template

8 0
4 years ago
Other questions:
  • Write about the future of Reliability and Security in Software Engineering.
    13·1 answer
  • Grace whistles while tickling Camille with a feather. Eventually, Camille starts to squirm and giggle every time Grace whistles,
    10·1 answer
  • Host A is a PC, connected to switch SW1 and assigned to VLAN 1. Which of the following are typically assigned an IP address in t
    13·1 answer
  • Charlie wants you to include the following topics in your presntation: an overview of project management and its hrity,a descrip
    15·1 answer
  • Which tab on the ribbon houses the sort functions?<br><br> Insert<br> Data<br> View<br> Home
    11·1 answer
  • Function countValues = CreateArray(endValue) % endValue: Ending value of countValues
    7·1 answer
  • The small company where you work needs to implement a second server for its accounting system, but does not have the funds to pu
    11·1 answer
  • Write a program that grades the written portion of the driver's license exam. The exam has 20 multiple choice questions (answers
    10·1 answer
  • Whats the overall mood of the song Rags2Riches by rod wave
    14·1 answer
  • _______ is the use of software to assist in the creation, analysis, and modification of the design of a component or product.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!