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
Studentka2010 [4]
2 years ago
7

Write a program second.cpp that takes in a sequence of integers, and prints the second largest number and the second smallest nu

mber. 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 .
Computers and Technology
1 answer:
sergey [27]2 years ago
4 0

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

Download cpp
You might be interested in
You have just installed the microsoft windows 7 operating system on your pc. which web browser is bundled with windows 7 and is
kirill [66]
The web browser that is automatically installed with windows 7 is Internet Explorer.

Hope this helps.
6 0
3 years ago
To insert the information of the data-label attribute directly before the data cell value, the _____ property is used.
sattari [20]

Answer:

Content is the correct answer to the following blank.

Explanation:

In the following FIB, Content is the property that is used to input the data directly in the data-label attribute earlier than the data cell value. In other words, it is used to insert the data or info of the label of the data attribute straightly without any barrier in the data cell value. So, that's why the following answer is true.

4 0
3 years ago
Upon running the ifconfig command, the IP address is listed along with the subnet mask in dotted decimal notation listed as 255.
vredina [299]

Answer:

The answer is "Option c"

Explanation:

In the given question only option c is correct because "/27" is the IP "255.255.255.224" is the same as "/27" in the terminology in CIDR, in which it uses the compact IP address as well as corresponding prefix expression and it terminology consists of an IP with a slash ('/') or a decimal number. Its count of 1-bit proceeding to the mask traditionally referred to it as the network mask.

5 0
3 years ago
A) Why should assembly language be avoided for general application development?
garri49 [273]

Answer:

(A) Assembly language should be avoided for general application development for the following reasons:

i. It is difficult to write assembly language codes. It does not contain many tools and in-built functions to help with the development of these applications.

ii. Since general application development requires that the application be machine independent, writing such applications in assembly language (which is a low level, machine dependent language) might be a pain as it would require that the writer have sufficient knowledge of hardware and operating systems.

(B) The following are the circumstances where assembly language should be used:

i. Assembly languages are low level languages that are very close to machine languages that the machine or processor understands. Therefore, when writing codes for programs that should directly communicate with the processor, assembly language should be used.

ii. Since assembly language codes are machine dependent, when there is a need to write applications for target machines, they should be used.

iii. If there is a need to have very great control of certain features of your application and resources to be consumed such as amount of RAM, clock speed e.t.c, assembly languages are a great tool.

(C) Some of the advantages of compiled language over an interpreted language are:

i. Compiled languages are way faster than interpreted languages because the compiled languages are converted directly into native machine codes that are easy for the processor to execute. Put in a better way, with compiled languages, codes are compiled altogether before execution and therefore reduces the overhead caused at run time. Interpreted languages on the other hand executes codes line after line thereby increasing the overhead at run time.

ii. Since codes are compiled first before execution in compiled languages, nice and powerful optimizations can be applied during the compilation stage.

(D) Interpreted languages could be chosen over compiled languages for the following reasons:

i. Interpreted languages are much more flexible and easier to implement than compiled languages as writing good compilers is not easy.

ii. Since interpreters don't need to convert first to intermediary codes as they execute these codes themselves, programs built with interpreters tend to be platform independent.

6 0
3 years ago
What file extension is used to name a compressed folder
fredd [130]

The file extension are:

1).zip

2).rar

3).tar

7 0
3 years ago
Other questions:
  • Which three phrases describe a wireframe
    12·1 answer
  • A computer abuse technique called a ____ involves inserting unauthorized code in a program, which, when activated, may cause a d
    11·1 answer
  • How can volunteering to help plan a fundraiser for your team or club be a way to develop your strengths?
    10·2 answers
  • Jim, the IT director, is able to complete IT management task very well but is usually two weeks late in submitting results compa
    5·1 answer
  • What behaviors are most common in a successful entrepreneurship
    9·1 answer
  • Which of the following tools and techniques shows theimpacts of one decision over another as well as the probability andcost of
    15·1 answer
  • Which is a feature of audio editing software?
    11·2 answers
  • Justice wrote a program and forgot to put the steps in the correct order. Which step does she need to review?
    5·2 answers
  • 8. What is the order of growth execution time of the push operation when using the LinkedStack class, assuming a stack size of N
    13·1 answer
  • Identify two different uses/applications of data in which biases in word embeddings might cause significant ethical harms, then
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!