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
5

Write a program that reads a list of integers into a vector, and outputs the two smallest integers in the list, in ascending ord

er. The input begins with an integer indicating the number of integers that follow. Ex: If the input is: 5 10 5 3 21 2 the output is: 2 and 3 You can assume that the list of integers will have at least 2 values. To achieve the above, first read the integers into a vector. Hint: Make sure to initialize the second smallest and smallest integers properly. Submit your .cpp code with this question's link. Output runs are not required.
Computers and Technology
1 answer:
AnnyKZ [126]3 years ago
8 0

Answer:

In C++:

#include <bits/stdc++.h>

#include <iostream>

#include <vector>

using namespace std;

int main(){

vector<int> vectItems;

cout << "Vector length: ";

int ln; cin>>ln;

int num;

for (int ikk = 0; ikk < ln; ikk++){

 cin >> num;

 vectItems.push_back(num);}

int small, secsmall;

small = secsmall = INT_MAX;  

for (int ikk = 0; ikk < ln; ikk++){

 if(vectItems[ikk] < small){

     secsmall = small;  

           small = vectItems[ikk];   }

 else if (vectItems[ikk] < secsmall && vectItems[ikk] != small) {

           secsmall = vectItems[ikk];} }

 cout<<small<<" "<<secsmall;

 return 0;}

Explanation:

See attachment for program file where comments are used for explanation

Download cpp
You might be interested in
Who should get the copyright credit for a piece of computer art: the CPU, the software, or the programmer? Explain your reasonin
yulyashka [42]

Answer:

The programmer.

Explanation:

The CPU (central processing unit or simply the processor) is the brain of the computer system, it processes data at a very fast rate depending on it's processing speed. But it only relates to speed of data processing and a link between components of the system.

A software is a program code at executes a task in the system. It a logical and follows an algorithm to solve a given task. Computer systems do not generate  lines of code by itself, but instead, A programmer writes the code to create the software used by the system.

6 0
3 years ago
When light hits an opaque object it will be _______________.
nikklg [1K]
None of it passes through. Most of the light is either reflected by the object or absorbed and converted to heat. Materials such as wood, stone, and metals are opaque to visible light.

Good luck
7 0
2 years ago
A technician is performing Windows preventative maintenance tasks on all computers in the organization. She wants a way to creat
Sedaia [141]

Answer:mmc.exe

Explanation:

mmc.exe is used to manage Windows network with a variety of snap-ins(administrative tools that can be added to the console and used to manage various aspects of your network).

The technician will.be able to use mmc.exe to to create a custom console containing only the tools she regularly launches and then distribute this custom console to each computer.

3 0
3 years ago
Which of the following are example of IT careers​
Iteru [2.4K]

Answer:

Where are the choices?

Explanation:

3 0
3 years ago
How is a microprocessor different from an integrated circuit?
pychu [463]

Answer:

Explanation:

Microprocessors are faster, smaller and less expensive than integrated circuits. ... Microprocessors control the flow of electrons and integrated circuits control the flow of protons.

6 0
2 years ago
Other questions:
  • Help please?
    10·1 answer
  • A troubleshooter's ability to design and test hypotheses in order to solve a technology problem is based on ____.
    14·1 answer
  • Why is it important to ensure that dns servers have been secured before implementing an e-mail system? awr138?
    10·1 answer
  • If you delete a sent message on gmail does the person still get it
    14·1 answer
  • Which of the following represent emerging classes of application software? Check all of the boxes that apply.
    9·3 answers
  • What is the first priority when building or using vex robots
    10·2 answers
  • Wanda manages an application that fluctuates in usage quite a bit. Sometimes it uses quite a few servers with lots of memory and
    14·1 answer
  • Driswers.
    13·2 answers
  • Which phrase best describes a scenario in Excel 2016?
    5·2 answers
  • You want to add a caption to a table. which tab contains this option?.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!