Question

In: Computer Science

(20 pts) Using your programming language of choice (from C++, Java, or Python) , also drawing...

  1. (20 pts) Using your programming language of choice (from C++, Java, or Python) , also drawing on your experience from program 1, read an integer, n from keyboard (standard input). This integer represents the number of integers under consideration. After reading that initial integer in, read n integers in, and print the minimum and maximum of all the integers that are read in.

Example:

Input

Output

7

1 5 3 6 9 22 2

Min: 1

Max: 22

C++ preferred

Solutions

Expert Solution

C++ code:

#include <iostream>
using namespace std;
int main()
{
//initializing n,min,max and number
int n,min,max,num;
//accepting n
cin>>n;
//accepting first number
cin>>num;
//assigning it to max
max=num;
//assigning it to min
min=num;
//looping from 0 to num-1
for(int i=0;i<n-1;i++){
//accepting number
cin>>num;
//checking if it is greater than max
if(num>max)
//assigning num to max
max=num;
//checking if it is less than min
if(num<min)
//assigning num to min
min=num;
}
//printing Min
cout<<"Min: "<<min<<endl;
//printing Max
cout<<"Max: "<<max<<endl;
return 0;
}


Screenshot:


Input and Output:


Related Solutions

Implement the MSI cache coherence protocol in your favorite programming language (C, C++, Java, python, etc.)....
Implement the MSI cache coherence protocol in your favorite programming language (C, C++, Java, python, etc.). Wikipedia has a nice high level description of the protocol. Consider only one level of cache which is a write back cache. Moreover, assume that there are 4 processing cores working on a single shared memory. To simplify, assume that you are writing the code for only one block of cache and that block can hold 4 different memory locations.
Discuss any API / libraries of your favorite programming language (e.g. python, c#, java etc.) that...
Discuss any API / libraries of your favorite programming language (e.g. python, c#, java etc.) that you have used/reused in any of your previous projects and how it contributes to the overall project.
Using a programming language of your choice, write a complete and fully functional program that uses...
Using a programming language of your choice, write a complete and fully functional program that uses reference and pointer types to swap two double precision floating-point numbers. The two numbers are read in by the program’s user. Use a proper prompt for each number. Use one function that uses formal parameter reference types to swap the two numbers Use another function that uses formal parameter pointer types to swap the two numbers. In the main or driver function, call these...
ASAP PLEASE... USE PYTHON Design and implement in a language of your choice, i.e. a C++...
ASAP PLEASE... USE PYTHON Design and implement in a language of your choice, i.e. a C++ , Java, or Python as you prefer, program that calculates the molecular weight of a formula. Your program should accept a formula in whatever form you choose as input from the user, and should display the molecular weight for that formula. Your program must be able to handle formulas that: consist of a single element, e.g., He    (worth 40 points) consist of a sequence of...
Using a programming language of your choice: 1) generate a range of wavelengths, 2) compute corresponding...
Using a programming language of your choice: 1) generate a range of wavelengths, 2) compute corresponding monochromatic blackbody intensity using a) Planck function, b) Rayleigh-Jeans simplification, and c) Wien simplification, and 3) plot the three resulting spectra (i.e., a diagram that shows how B(λ) changes with λ). Using this figure explain the phenomenon of “ultraviolet catastrophe”. Please include the code (not only figure) in your answer.
Choose one of the following cryptography techniques and implement it using (java )programming language. Your program...
Choose one of the following cryptography techniques and implement it using (java )programming language. Your program should provide the user with two options Encryption and Decryption, with a simple UI to get the input from the user, and view the result. You can use any restriction you need for the user input but you need to clarify that and validate the user input base on your restriction. ● Feistel ● Keyword columnar ● Any cryptosystem of your choice (needs to...
HI, ANY PROGRAMMING LANGUAGE WOULD WORK, FROM PYTHON TO C++, MOST PREFERABLY OR ELSE ANY FOR...
HI, ANY PROGRAMMING LANGUAGE WOULD WORK, FROM PYTHON TO C++, MOST PREFERABLY OR ELSE ANY FOR YOUR CONVENIENCE. Let f(x) = x6 + 7x5− 15x4− 70x3 + 75x2 + 175x − 125. a.) Write a program that carries out the Secant Method on f(x). You do not need to make your program take arbitrary input (i.e. you can tailor it to this specific f(x)). Your program should take as input the appropriate number of initial guesses, an interval [a, b]...
Programming assignment (100 pts): In the C++ programming language write a program capable of playing Tic-Tac-Toe...
Programming assignment (100 pts): In the C++ programming language write a program capable of playing Tic-Tac-Toe against the user. Your program should use OOP concepts in its design. You can use ASCII art to generate and display the 3x3 playing board. The program should randomly decide who goes first computer or user. Your program should know and inform the user if an illegal move was made (cell already occupied). The program should also announce if one of the players wins...
Please solve using simple python programming language and make it easy to understand explain your code...
Please solve using simple python programming language and make it easy to understand explain your code as I am a beginner, use appropriate variable names which make the code easy to understand and edit if needed. A subsystem responsible for delivering priority numbers to an automated irrigation system has stopped working and you need to deliver a quick fix that will work until the actual subsystem is fixed by senior developer. As you are the newest addition to the development...
Programming Language: JAVA In this assignment you will be sorting an array of numbers using the...
Programming Language: JAVA In this assignment you will be sorting an array of numbers using the bubble sort algorithm. You must be able to sort both integers and doubles, and to do this you must overload a method. Bubble sort work by repeatedly going over the array, and when 2 numbers are found to be out of order, you swap those two numbers. This can be done by looping until there are no more swaps being made, or using a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT