Write a program second.cpp that takes in a sequence of integers, and prints the second largest number and the second smallest number. Note that in the case of repeated numbers, we really mean the second largest and smallest out of the distinct numbers (as seen in the examples below). You may only use the headers: and .

Answers

Answer 1

Answer:

The program is as follows:

#include <iostream>

#include <vector>

using namespace std;

int main(){

   int n;

   cout<<"Elements: ";

   cin>>n;

   vector <int>vectnum;

   int numInp;

   for (int i = 1; i <= n; i++){        cin>>numInp;        vectnum.push_back(numInp);    }

   int big, secbig;

   big = vectnum.at(0);      secbig = vectnum.at(1);

   if(vectnum.at(0)<vectnum.at(1)){     big = vectnum.at(1);  secbig = vectnum.at(0);   }

   for (int i = 2; i< n ; i ++) {

     if (vectnum.at(i) > big) {

        secbig = big;;

        big = vectnum.at(i);

     }

     else if (vectnum.at(i) > secbig && vectnum.at(i) != big) {

        secbig = vectnum.at(i);

     }

  }

  cout<<"Second Largest: "<<secbig<<endl;

  int small, secsmall;

  small = vectnum.at(1);       secsmall = vectnum.at(0);

  if(vectnum.at(0)<vectnum.at(1)){ small = vectnum.at(0);  secsmall = vectnum.at(1);   }

  for(int i=0; i<n; i++) {

     if(small>vectnum.at(i)) {  

        secsmall = small;

        small = vectnum.at(i);      }

     else if(vectnum.at(i) < secsmall){

        secsmall = vectnum.at(i);      }   }

  cout<<"Second Smallest: "<<secsmall;

  return 0;

}

Explanation:

See attachment for explanation


Related Questions

Question # 18
Dropdown
A(n)
is the tool that will help you the most when developing the content you will use in your presentation.

Answers

Your answer is outline.

An outline is the tool that will help you the most when developing the content you will use in your presentation.

What is presentation?

A presentation is a method of communicating information from a speaker to an audience.

Presentations are usually demonstrations, introductions, lectures, or speeches intended to inform, persuade, inspire, motivate, build goodwill, or introduce a new idea/product.

An outline is a list of the main topics and subtopics that you intend to cover in your presentation in a hierarchical order.

It can assist you in ensuring that your ideas flow logically and that no important points are overlooked.

A storyboard, on the other hand, is a visual representation of your presentation that shows the order of your slides, the images or videos you intend to use, and the text that will go with them.

Thus, the answer is outline.

For more details regarding presentation, visit:

https://brainly.com/question/938745

#SPJ7

1) SuperFetch is a memory-management technique that a) determines the type of RAM your system requires. b) makes the boot-up time for the system very quick. c) preloads the applications you use most into system memory. d) defragments the hard drive to increase performance.

Answers

Answer:

c

Explanation:

It preloads the apps and softwares that you use most into thr memory so that they can boot up faster.But it consumes more ram.

explain 5 important of using a word processor​

Answers

Answer:

Spelling

Word processors contain an electronic spell checker. The student writer has immediate feedback about misspelled words. Student must discern which of the computer-generated spellings is correct for the context. Teachers no longer have to red-ink spelling errors. They can focus on the few exceptions the spellchecker does not catch.

Security

Teachers and students gain a sense of security about losing assignments. When the student saves her work, she avoids the possibility of the assignment being lost or misplaced. If an assignment is ever misplaced, a replacement can be easily printed.

Legibility

Teachers benefit by receiving a readable copy that is easy to grade. Students with poor handwriting can increase their scores with better looking papers. Students should be instructed to turn in copies of work in a readable font.

Publishing

Work done on a word processor can easily published on a bulletin board. Teachers can create electronic anthologies of their students' writings. Each student can receive an electronic copy of published works with no printing costs.

Mobility

Work done on a word processor and saved on the Internet is highly portable and accessible from any computer with Internet access. Dogs do not eat papers in cyberspace. "I forgot it at home" is irrelevant. Just log onto the nearest computer and your work appears on the screen.

Explanation:

Answer:

1. they are faster creation of document.

2.document can be stored for future use.

3. quality document are created.

4. it has access to higher variation.

5. tiredness Is greatly reduced.

state the function of a URL in a website​

Answers

Answer:

It's purpose is to access a webpage.

Explanation:

A URL contains detailed information on the webpage such as, the domain name, protocol, and path. This information directs the browser to the desired page.

Accenture is helping a large retailer transform their online sales and services. The Data Analyst audits the client’s customer journey and maps out the kind of data they need to collect at each touch point. How does this help the client achieve their objectives?

Answers

Answer:

d. by increasing their customer knowledge and leveraging that information to improve customer experience

Explanation:

Consumers are at the heart of all businesses as they are the ones who our product are targeted. They purchase these goods and the company makes profit. Therefore, it is paramount for businesses to identify their target consumers in other to understand their preference and serve them accordingly. With data analytics, a consumers purchase history, likes and viewed products may be used to improve relationship between consumers and service providers. Once a consumer's preference is anlysed using data, then this is leveraged to improve the kind of service offered to such consumer leasing to better consumer experience.

The way in which the auditing of the client’s customer journey and mapping out the kind of data they need to collect at each touch point helps the client achieve their objectives is;

A: by updating their sales platform and adding new features

The missing options are;

A. by updating their sales platform and adding new features

B. by shifting the focus away from the customer and towards new products or services

C. by identifying products that are poor sellers and removing them from the inventory

D. by increasing their customer knowledge and leveraging that information to improve customer experience.

Looking at the given options, the one that is correct is Option A. This is because the company will by that medium, introduce new features that would be very useful in making the sales platform to be more efficient.

Now, Accenture is a company that does consultancy services by providing digital solutions to companies to help them to optimize their business operations. Thus, their different tools will help to give this their client an extra edge that will give them a good advantage over their competitors.

Read more about Accenture at; https://brainly.com/question/25702705

In which SDLC step does the company translate broad, user-oriented systems requirements into the detailed specifications used to create a fully developed system

Answers

Answer:

Physical design.

Explanation:

Systems development life cycle (SDLC) is a strategic process that involves determining the overall system architecture, which is typically comprised of hardware, end users, physical processing components, software, and the communication channel that will effectively and efficiently satisfy the essential requirements of the system.

The system inputs and outputs is typically designed along with a plan of how the system's features will be navigated.

Basically, system design is divided into two (2) categories and these includes;

I. Logical design.

II. Physical design.

Furthermore, the design of service systems involves the process of planning, creating infrastructure, building communication, organizing staffs and standardization of a system so as to improve its quality and business relationships between the service provider and its clients.

In the physical design of systems development life cycle (SDLC), broad, user-oriented systems requirements are obtained from end users by companies and then translated into the detailed specifications that would be used to create a fully developed system.

type of operating system used i handleheld device

Answers

Answer:

6

Explanation:

Palm OSPocketOSSymbianOSLinuxOSWindowsAndroid

What are the characteristic features of TFTP?

Answers

Answer:

TFTP Server is used for simple file transfer

Explanation:

Example

boot-loading remote devices

Synapse is not working and is crashing every time you attach it. What should you do?

1. Contact a staff
2. Wait for it to be fixed
3. delete it
4. Spam dm everyone

Answers

Contact a staff memeber

In this lab, you complete a C++ program that uses an array to store data for the village of Marengo.
The program is described in Chapter 8, Exercise 5, in Programming Logic and Design. The program should allow the user to enter each household size and determine the mean and median household size in Marengo. The program should output the mean and median household size in Marengo. The file provided for this lab contains the necessary variable declarations and input statements. You need to write the code that sorts the household sizes in ascending order using a bubble sort and then prints the mean and median household size in Marengo. Comments in the code tell you where to write your statements.
Instructions
Make sure that the file HouseholdSize.cpp is selected and open.
Write the bubble sort.
Output the mean and median household size in Marengo.
Execute the program by clicking the Run button and the bottom of the screen.
Enter the following input, and ensure the output is correct. Household sizes: 4, 1, 2, 4, 3, 3, 2, 2, 2, 4, 5, 6 followed by 999 to exit the program.
Here is my code so far. I need help finishing it (printing the mean & median, etc). Thanks so much:
// HouseholdSize.cpp - This program uses a bubble sort to arrange up to 300 household sizes in
// descending order and then prints the mean and median household size.
// Input: Interactive.
// Output: Mean and median household size.
#include
#include
using namespace std;
int main()
{
// Declare variables.
const int SIZE = 300; // Number of household sizes
int householdSizes[SIZE]; // Array used to store 300 household sizes
int x;
int limit = SIZE;
int householdSize = 0;
int pairsToCompare;
bool switchOccurred;
int temp;
double sum = 0;
double mean = 0;
double median = 0;
// Input household size
cout << "Enter household size or 999 to quit: ";
cin >> householdSize;
// This is the work done in the fillArray() function
x = 0;
while(x < limit && householdSize != 999)
{
// Place value in array.
householdSizes[x] = householdSize;
// Calculate total of household sizes
sum+= householdSizes[x];
x++; // Get ready for next input item.
cout << "Enter household size or 999 to quit: ";
cin >> householdSize;
} // End of input loop.
limit = x;
// Find the mean
// This is the work done in the sortArray() function
pairsToCompare = limit - 1;
switchOccured = true;
while(switchOccured == true)
{
x = 0;
switchOccured == false;
while (x < pairsToCompare)
{
if(householdSizes[x]) > householdSizes[x+1])
{
//perform switch
}
x++;
}
pairsToCompare--;
}
// This is the work done in the displayArray() function
//Print the mean
// Find the median
median = (limit-1) / 2;
if (limit % 2 ==0)
{
cout << "Median is: " << (householdSizes[(int)median] + householdSizes[(int)median + 1]) / 2.0 << endl;
}
else {
// Print the median household size
}
// Print the median
return 0;
} // End of main function

Answers

Answer:

For the mean, do the following:

mean = sum/limit;

cout<<"Mean: "<<mean;

For the median do the following:

for(int i = 0; i<limit; i++) {

  for(int j = i+1; j<limit; j++){

     if(householdSizes[j] < householdSizes[i]){

        temp = householdSizes[i];

        householdSizes[i] = householdSizes[j];

        householdSizes[j] = temp;       }    } }

median= (householdSizes[(limit-1)/2]+householdSizes[1+(limit-1)/2])/2.0;

if((limit - 1)%2==0){

   median = householdSizes[limit/2];

}

cout<<endl<<"Median: "<<median;

Explanation:

The bubble sort algorithm in your program is not well implemented;

So, I replaced the one in your program with another.

Also, some variable declarations were removed (as they were no longer needed) --- See attachment for complete program

Calculate mean

mean = sum/limit;

Print mean

cout<<"Mean: "<<mean;

Iterate through each element

for(int i = 0; i<limit; i++) {

Iterate through every other elements forward

  for(int j = i+1; j<limit; j++){

Compare both elements

     if(householdSizes[j] < householdSizes[i]){

Reposition the elements if not properly sorted

        temp = householdSizes[i];

        householdSizes[i] = householdSizes[j];

        householdSizes[j] = temp;       }    } }

Calculate the median for even elements

median= (householdSizes[(limit-1)/2]+householdSizes[1+(limit-1)/2])/2.0;

Calculate the median for odd elements

if((limit - 1)%2==0){

   median = householdSizes[limit/2];

}

Print median

cout<<endl<<"Median: "<<median;

Does anyone know how to fix this? Everytime i make a new page it only types in the middle of the page. I want to type at the top

Answers

Answer:maybe start a new page or try hitting delete

Explanation:

The network performance is said to be biased when _________.

a) It performs well on train set but poorly on dev set
b) it performs poorly on train set
c) Both the options
d) None of the options

Answers

Answer:

the answer for the question is B

The network performance is said to be biased when it performs poorly on train set.

What is network performance?

A measurement regarding service or the state of quality of network received by the consumer is known as network performance. Operators can control the upper limit of a network performance.

When network operators or service providers put a cap and lower the speed of a network on a train set, it is said to be a biased network performance.

Hence, option B holds true regarding network performance.

Learn more about network performance here:

https://brainly.com/question/12968359

#SPJ2

tool that help to monitor the ongoing performance of the platform for Accenture​

Answers

Answer:

MyConcerto

Explanation:

Accenture may be described as an industry leader which renders professional services capable of solving various business problems by leveraging the use technology involving data and business intelligence to proffer solutions to their clients needs. The MyConcerto firmly known as the Accenture Intelligence Enterprise platform is designed to continously help businesses measure performance, identify shortfalls and proffer solutions using data driven insight. It offered a fully automated platform with predefined solutions geared at accelerating business decisions and adaptive solution.

MyConcerto is a tool which helps to monitor the ongoing performance of the

platform for Accenture​.

Myconcerto is a digital platform which brings together and incorporates

innovation and leadership qualities. It involves the use of technology and

solutions which results in exponential business outcomes.

These qualities help in the monitoring process of ongoing performance

which is available on Accenture.

Read more about Accenture here https://brainly.com/question/24937450

Claire needs to make an SRS document. Help her identify the given section and subsection.

The ___ subsection mentions the list of factors that may influence the requirements specified in the SRS. This subsection is part of the section named ___

Blank 1:
A. Scope
B. Purpose
C. Assumptions

Blank 2:
A. Introduction
B. General Description
C. Specific Requirements

Answers

Answer:

C and B in that order

Explanation:

A local router is configured to limit the bandwidth of guest users connecting to the Internet. Which of the following best explains the result of this configuration as compared to a configuration in which the router does not limit the bandwidth?

a. The amount of time it takes guest users to send and receive large files is likely to decrease.
b. The number of packets required for guest users to send and receive data is likely to decrease.
c. Guest users will be prevented from having fault-tolerant routing on the Internet.
d. Guest users will be restricted in the maximum amount of data that they can send and receive per second.

Answers

Answer:

The correct option is d. Guest users will be restricted in the maximum amount of data that they can send and receive per second.

Explanation:

Bandwidth can be described as the maximum data transfer that an internet connection or a network has. It gives a measure of the amount of data that can be transmitted over a particular connection in a particular amount of time. For instance, the capacity of a gigabit Ethernet connection is 1,000 megabits per second (Mbps) (which also translates to 125 megabytes per second).

Therefore, when a local router is configured to limit the bandwidth of guest users connecting to the Internet, it will restrict the the maximum amount of data that they can transmit per second.

Therefore, the correct option is d. Guest users will be restricted in the maximum amount of data that they can send and receive per second.

What lets you do many things, like write book reports and stories?

Application Programs

Antivirus Software

Email

Duct Tape

Answers

A -
Application programs
application progarms lets you do many things

In the header element, insert a navigation list containing an unordered list with the items: Home, Race Info, and FAQ. Link the items to the dr _index.html, dr_info.html, and dr_ faq.html files respectively.
Home
Race info
FAQ

Answers

Answer:

Explanation:

The following is a barebones HTML document that contains the Unordered List inside the header tag as requested. The list items are also wrapped around links so that they link to the requested pages and take you there when they are clicked. These html files need to be in the same folder as this code in order for it to take you to those pages. The code can be seen below.

<!DOCTYPE html>

<html>

<head>

<ul>

   <li><a href="dr _index.html">Home</a></li>

   <li><a href="dr_info.html">Race Info</a></li>

   <li><a href="dr_ faq.html">FAQ</a></li>

</ul>

</head>

<body>

</body>

</html>

Which programming paradigm does the programming language JavaScript follow?
A. procedural programming
B. object-oriented programming
C. functional programming
D. Imperative programming​

Answers

Its not functional programming (sorry)

Answer:

Object-oriented programming

Explanation:

Just took the test and got it right

Happy to help !!

3. Why is human resource plan made​

Answers

Answer: See explanation

Explanation:

Human Resource Planning refers to the process whereby the future human resource requirements of an organization is predicted and how the current human resources that the organization has can be used to fulfill the goals.

Human resources planning is made as it's useful helping an organization meet its future demands by supplying the organization with the appropriate people.

Human resource planning also allows organizations plan ahead in order to have a steady supply of effective and skilled employees. It also brings about efficient utilization of resources. Lastly, it leads to better productivity and organizational goals will be achieved.

write a java program to input two double type numbers and by using suitable mathematical functions print the maximum and minimum numbers out of the two numbers.
[tex]java \: me \: likhna \: ok[/tex]

Answers

Answer:

The program in Java is as follows:

import java.util.Scanner;

public class Main{

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 double n1, n2;

 n1 = input.nextDouble();

 n2 = input.nextDouble();

 double Max = Math.max(n1,n2);

 double Min = Math.min(n1,n2);

 System.out.println("Max: "+Max);

 System.out.println("Min: "+Min); }}

Explanation:

This declares the numbers

 double n1, n2;

This gets input for n1

 n1 = input.nextDouble();

This gets input for n2

 n2 = input.nextDouble();

This gets the max of both using the max function

 double Max = Math.max(n1,n2);

This gets the min of both using the min function

 double Min = Math.min(n1,n2);

This prints the max

 System.out.println("Max: "+Max);

This prints the min

 System.out.println("Min: "+Min);

Which of the following class definition defines a legal abstract class Group of answer choices public class Rectangle abstract { public abstract double findArea ( ); } public abstract class Rectangle { public abstract double findArea ( ); } public class Rectangle { public abstract double findArea ( ); } public class abstract Rectangle { public abstract double findArea ( ); }

Answers

Question

Which of the following class definition defines a legal abstract class Group of answer choices

(a)

public class Rectangle abstract {

   public abstract double findArea ( );

   

}

(b)

public abstract class Rectangle {

   public abstract double findArea ( );

   

}

(c)

public class Rectangle {

   public abstract double findArea ( );

   

}

(d)

public class abstract Rectangle {

   public abstract double findArea ( );

   

}

Answer:

(b)

public abstract class Rectangle {

   public abstract double findArea ( );

}

Explanation:

When a class is declared with the abstract keyword, the class is called an abstract class. Abstract classes cannot be instantiated and may include one or more abstract methods. If a class contains an abstract method, then it (the class) must be declared abstract.

In Java, abstract classes are defined using the following format:

[access_modifier] abstract class [name_of_class]

[access_modifier] specifies the access modifier of the class which could be public, private, e.t.c

abstract is the keyword that specifies that the class is an abstract class.

class is a keyword used for defining classes

name_of_class specifies the name of the class.

The only option that fulfils this format is option b where;

(i) The access modifier is public

(ii) The name of the class is Rectangle

Option a is not correct because the abstract keyword is supposed to come before the class keyword.

Option c is not correct because the keyword abstract is missing. In other words, the class must be declared abstract since it contains abstract method findArea();

Option d is not correct because the abstract keyword is supposed to come before the class keyword.

What is the difference between autofocus and autocomplete

Answers

Answer:

https://www.c-sharpcorner.com/interview-question/explain-autofocus-and-autocomplete-attribute

found this on a website hope you find it useful !

Other Questions
What might have motivated Nazi SSofficers to carry out orders against Jews? What is the value of P Find the probability that a randomly placed point falls within the smaller, inner circle.The unshaded portion has a radius of 5 centimeters. The shaded path has a width of 8 centimeters.5/825/16964/78.515/24 McCarthyism primarily and fundamentally reflected A. fears of Soviet attack. B. the fears and hatreds of many Americans, who were suspicious of things foreign, liberal, internationalist, European, or intellectual. C. hostility to the Truman administration for firing General MacArthur. D. the threat that Communist-led insurgencies would overthrow the pro-Western governments in developing countries in Asia. Using Internet resources, find at least five organizations that offer Software as a Service (SaaS). How do their services benefit their users? Digestion of dietary fats _____. a. occurs primarily in the large intestine b. occurs primarily in the stomach c. involves the small intestine but not the pancreas d. results in triglycerides, phospholipids, and sterols as end products e. requires bile and lipase Help plz:)))Ill mark u Brainliest Solve by elimination 2x - 3y = -6-2x - 2y = 26 Are the Wakandans wrong to distance themselves from the struggles of black people in Africa and around the globe? Why or why not? Be specific. Can any one psay what is monmon meaning I think it's and alien You roll 2 number cubes. What is the probability of rolling double twos?EZ points! Which expression will simplify (3a+6) (7a-2) The following is selected financial information for Osmond Dental Laboratories for 2021 and 2022: 20212022 Retained earnings, January 1$53,000? Net income 40,00045,000 Dividends 12,00025,000 Common stock 78,000? Osmond issued 3,000 shares of additional common stock in 2022 for $22,000. There were no other stock transactions. Prepare a statement of stockholders' equity for the year ended December 31, 2022. (Amounts to be deducted should be indicated with minus sign.) 1. A quadrilateral has one pair of parallel sides with lengths 2 inches and 3 inches, and two angles that each measure 42 degrees What is the shape of the quadrilateral? "Speaking of fossil fuels; the chart above shows the common uses for which fossil fuel?"*PetroleumCoalNatural GasNuclear Describe TWO environmental consequences, other than those related to the loss of boreal forest habitat, that result from the extraction of bitumen or the transportation of synthetic oil to customers. Write the equation of the linear relationship in slope-intercept form. Quick answer will be good graph (-5,0) (9,0) (8,-39) What is the solution of-+-