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
cupoosta [38]
3 years ago
11

Write a program that asks the user to enter five different, integer numbers. The program then reports the largest number and the

smallest number.
Use the if statement, but no loops.
Computers and Technology
1 answer:
Akimi4 [234]3 years ago
4 0

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// variables

  int minn=INT_MAX;

   int maxx=INT_MIN;

   int n1,n2,n3,n4,n5;

   cout<<"enter five Numbers:";

   //read 5 Numbers

   cin>>n1>>n2>>n3>>n4>>n5;

   // find maximum

   if(n1>maxx)

    maxx=n1;

    if(n2>maxx)

    maxx=n2;

    if(n3>maxx)

    maxx=n3;

    if(n4>maxx)

    maxx=n4;

    if(n5>maxx)

    maxx=n5;

   // find minimum

   if(n1<minn)

    minn=n1;

    if(n2<minn)

    minn=n2;

    if(n3<minn)

    minn=n3;

    if(n4<minn)

    minn=n4;

    if(n5<minn)

    minn=n5;

   // print maximum and minimum

   cout<<"maximum of five numbers is: "<<maxx<<endl;

   cout<<"minimum of five numbers is: "<<minn<<endl;

return 0;

}

Explanation:

Declare two variables "minn" & "maxx" and initialize them with INT_MAX and INT_MIN respectively.Then read the five number from user and compare it with "minn" & "maxx" ,if input is greater than "maxx" then update "maxx" or if input is less than "minn" then update the "minn". After all the inputs, "minn" will have smallest and "maxx" will have largest value.

enter five Numbers:5 78 43 55 12

maximum of five numbers is: 78

minimum of five numbers is: 5

You might be interested in
Jane is a postproduction crewmember for a film. Her responsibilities include arranging all the scenes that have been shot into t
navik [9.2K]
Jane is the editor of the film.
7 0
3 years ago
python A pet shop wants to give a discount to its clients if they buy one or more pets. The discount is equal to 20 percent of t
Artyom0805 [142]

Answer:

The following are the program in the Python Programming Language.

#define function

def discount(prices, isPet, nItems):

 # declare and initialize variables to 0

 i = 0

 cost = 0

 pets = 0

 item = 0

 item_Cost = 0

 #set the while loop

 while(i < nItems):

   #check the items of the variable

   if isPet[i]:

     #add and initialize in the cost

     cost += prices[i]

     #increament in the variable by 1

     pets += 1

   #otherwise

   else:

     #add and initialize in the item_Cost

     item_Cost += prices[i]

     #increament in the variable by 1

     item += 1

   #then increment in the variable by 1

   i += 1

 #check the pet is greater than equal to 1  

 #and item is greater than equal to 5

 if(pets >= 1 and item >=5):

   #then, print the message

   print("You receive discount")

   #set discount of the items

   discount = 0.2 * item_Cost

   # calculate bill after deducting discount

   bill = cost + item_Cost - discount

   #print the bill

   print("Final Bill amount is", bill)

 #otherwise

 else:

   #print the message

   print("You do not receive any discount")

   #calculate bill without deducting discount

   bill = cost + item_Cost

   #print the final bill

   print("Final Bill amount is", bill)

#set empty list type variables

price = []

pet = []

#set the infinite loop

while True:

 #get input from the user

 sprice = int(input("Enter the price (-1 to quit): "))

 #check that price is not equal to the -1

 if(sprice != -1):

   #add price in the list

   price.append(sprice)

   #ask for choice from the user

   choice = input("Is it a pet (Y / N)? ")

   #check the choice of the user is y or Y

   if(choice == 'Y' or choice == 'y'):

     # then, add in the pet

     pet.append(True)

   #otherwise

   else:

     #not add in the pet

     pet.append(False)

   print("")

 #break the loop

 else:

   break

#declare variable that store the length

items = len(price)

#call and initialize the variable

discount(price, pet, items)

<u>Output</u>:

Enter the price (-1 to quit): 96

Is it a pet (Y / N)? y

Enter the price (-1 to quit): 69

Is it a pet (Y / N)? n

Enter the price (-1 to quit): 41

Is it a pet (Y / N)? n

Enter the price (-1 to quit): 52

Is it a pet (Y / N)? n

Enter the price (-1 to quit): 96

Is it a pet (Y / N)? n

Enter the price (-1 to quit): 74

Is it a pet (Y / N)? n

Enter the price (-1 to quit): -1

You receive discount

Final Bill amount is 361.6

Explanation:

<u>The following are the description of the program</u>.

  • Firstly, define the function 'discount()' and pass the arguments 'prices', 'isPet' and 'nItems' in its parameter.
  • Then, declare and initialize the variables 'i' to 0, 'item_Cost' to 0
  • , item to 0, 'cost' to 0 and 'pets' to 0.
  • Then, set the while loop to add the price of the items and the cost of the pets.
  • Set the if-else conditional statement to check the pet is greater than equal to 1 and the items are greater than equal to 5 then, set the discount and print the bill after deduction.
  • Otherwise, print the bill without deduction.
  • Finally, set two list type variable then, set the infinite while loop that gets input from the user and check that the variable is not equal to -1 then append the data in the list then again check the user input then append in pet otherwise not append in pet and break the loop. Then, set the variable that stores the length of the price and call the following function by passing arguments in its parameter.
8 0
3 years ago
The merge process involves which two types of files?
VMariaS [17]
Base on the question is asking to choose among the following choices that states the two type of files that is involve in the merge process and base on my research and further investigation, the possible answer would be letter D. Main document and Data source. I hope you are satisfied with my answer and feel free to ask for more 
8 0
3 years ago
)duplicate hash code
mash [69]

Answer:A) Create collisions

Explanation: Hash codes are the numeric codes present in the programming infrastructures which are responsible for focusing on the object while the equality testing is in process. Hash codes does not display the property of having a permanent value.

When there is the creation of the duplicate hash codes then ,chances of collision arise because they search for the particular object and cannot have the same numeric value.

5 0
3 years ago
Explain how will you know the number of slides used in the presentation.​
EastWind [94]
You can tell the number of slides used in a presentation by looking to the left of the screen on the title page and it will show you. This also depends on what site you are using
8 0
3 years ago
Other questions:
  • The chief architect now needs to design a memory with an addressability of 32 bits. Suppose the architect can only use the same
    6·1 answer
  • What feature should an administrator use to meet these requirements?
    8·1 answer
  • When you choose the ____ compression setting, photos are compressed to the resolution specified on the advanced tab in the power
    13·2 answers
  • - The concept of communication competence suggests there is no single "ideal" or "effective" way to communicate in every situati
    6·2 answers
  • Who can pick up GPS signals
    14·1 answer
  • 5.) Spam messages account for what percentage of all email?
    15·2 answers
  • What is a GUI?
    11·1 answer
  • Identify a true statement about a flat file system. a. Data in a flat file system can be updated efficiently. b. Data in a flat
    9·1 answer
  • What is the difference between the throw statement and the throws clause?
    10·1 answer
  • Which visual aid would be best for showing changes inacts population size over time?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!