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
Discuss any five positive and five Negative impact<br>of ICT on society​
mojhsa [17]

Answer:

The technology of information communication has the capacity to transform society. It plays a key part and provides the infrastructure needed to achieve each of the United Nations Sustainable Development Goals. It also allows financial integration by m-commerce and lets people connect instantly to millions.

ICT has a particularly important impact on business. It allows people to exchange knowledge and advice immediately and establish a website or online shop at a low cost, thus reducing the obstacles to starting a business dramatically. As such, it is a major factor in change and the maturity of ICTs is strongly connected to economic growth.

Explanation:

Effects of ICT

As a human beings, we are always associated in our everyday life with many essential things. The use of ICT equipment in our lifestyle has simplified many time-consuming calculations and difficult tasks, and social contacts have been strengthened. ICT has affected life by enhancing the timely distribution of media information and improved home and workplace communications via social networking, e-mail, etc.

The quality of human life has been greatly improved by ICT. For example, it could take a few days for a letter to come to the recipient, but a single minute for an e-mail to reach. ICT offers a broader understanding and information for each facility  24 Hrs X 7 days. In the following, ICT affects different fields of daily living.

Positive Impacts of ICT:

  • As domestic and home businesses.
  • As social connectivity.
  • As E-learning/ As education
  • As for shopping/trading
  • As for banks
  • As a job/jobs

Negative Impacts of ICT:

  • Face-to-face interaction reduced.
  • Social Decoupling.
  • Physical activity/health issues reduced.
  • Cost.

4 0
2 years ago
What is machine level language ?​
NeX [460]

Answer:

The machine-level language is a language that consists of a set of instructions that are in the binary form 0 or 1.

5 0
2 years ago
Sara is asked to create a controller for light sensors. When the light falls on the sensor, it needs to indicate when a particul
Marrrta [24]

Answer:

Arduino

Explanation:

<em>Arduino is a free and open-source electronics platform with simple hardware and software. Arduino boards can read inputs, turn on a sensor and transform it into an output, activate a motor, and turn on an LED. Sara may direct her board by sending a series of instructions to the board's microcontroller. To accomplish so, she used the Arduino programming language and the Arduino Software (IDE), both of which are founded on Processing.</em>

7 0
1 year ago
Dawn needs to insert a macro into a Word document. Where can she find the Insert Macro dialog box?
amid [387]

Answer:

Developer tab

Explanation:

Inserting the Macro dialog box can be confusing for many people because the "Developer tab," where it can be found, is <em>hidden by default</em> in Microsoft Word. In order to add this to the ribbon, all you have to do is to go to the File tab, then click Options. After this, click Customize Ribbon. Under this, choose Main Tabs, then select the Developer check box. The Developer tab will then become visible. You may now insert a macro.

6 0
2 years ago
6
Allisa [31]

Answer:

objective of sustainable development are:

Explanation:

1.to help in poverty alleviation

2.to conserve the environment effectively

3.to gain human development and progress

4.to use resources and means carefully

6 0
3 years ago
Other questions:
  • How often do you give or receive interpersonal support through social media? Consider times when you’ve exchanged supportive mes
    13·1 answer
  • Using the ____ browsing mode offered by some browsers can prevent personal information from being left on a public computer.
    9·1 answer
  • What are the three major functions of a game engine?
    15·1 answer
  • Google Slides saves your work to Google Drive. PowerPoint has the option to save to OneDrive. Both of these solutions are in the
    9·1 answer
  • Write a program that allows the user to enter a time in seconds and then outputs how far an object would drop if it is in free f
    7·1 answer
  • What makes the huns a formidable force for the roman empire?
    5·1 answer
  • When would you use the AutoFit to Contents option?
    15·1 answer
  • 1. Write a 400-500 word research report about Burke High School.
    6·1 answer
  • How do you get The gold chip on Megaman x3 snes I want To know
    11·1 answer
  • When you start a new, blank document, you usually end up changing the font to arial 11. 5 point. How can you make these settings
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!