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
Which wireless communication is typically limited to six feet of distance?
Anni [7]

Answer:

nfc

Explanation:

8 0
3 years ago
2. How do upgrading and retraining help you cope with change?
Luden [163]
<h2>Upgrading and retraining are mandatory to move along with the world.</h2>

Explanation:

Let us understand the term deeply,

Upgrading - Updating yourself with the latest

Retraining - learning new skills

Let me give you a real-life example which is nothing but "mobiles". If you are not updated then:

  • you will sit with mobile to make calls and
  • do money transactions only by stepping into the bank,
  • connect with people only through calls or directly visiting them,
  • distance break up the relationship,
  • booking tickets in classical way, etc.

These could be done in one touch if you have latest mobile with necessary applications.

In a similar way, we need to get retrained to get to learn new skills, technologies so that we can do our job the best, to be on track, be productive, convert your valuable knowledge in terms of money, to be peaceful in day today transactions, etc.

7 0
3 years ago
8.9 code practice edhesive
nadezda [96]

Answer:

.

Explanation:

7 0
3 years ago
Design pseudocode for a program that will permit a user to store exactly 50 numbers in an array. Create an array big enough to h
galben [10]

Answer:

#include<stdio.h>

//declare a named constant

#define MAX 50

int main()

{

   //declare the array

   int a[MAX],i;

   //for loop to access the elements from user

   for(i=0;i<MAX;i++)

   {

      printf("\n Enter a number to a[%d]",i+1);

      scanf("%d",&a[i]);

  }

  //display the input elements

  printf("\n The array elements are :");

  for(i=0;i<=MAX;i++)

  printf(" %d ",a[i]);

}

Explanation:

PSEUDOCODE INPUTARRAY(A[MAX])

REPEAT FOR I EQUALS TO 1 TO MAX

PRINT “Enter a number to A[I]”

READ A[I]

[END OF LOOP]

REPEAT FOR I EQUALS TO 1 TO MAX

PRINT A[I]

[END OF LOOP]

RETURN

ALGORITHM

ALGORITHM PRINTARRAY(A[MAX])

REPEAT FOR I<=1 TO MAX

PRINT “Enter a number”

INPUT A[I]

[END OF LOOP]

REPEAT FOR I<=1 TO MAX

PRINT A[I]

[END OF LOOP]

6 0
3 years ago
When looking at a maple tree, you learn that many maple tree leaf cells are capable of creating food from the sun and sustaining
Usimov [2.4K]

it tells you that the sun give the msple tree energy to produce food for its leaf's and if it can no longer produce enough energy to make food for the leaf's of the maple tree then the tree will either die of no energy or die of no leaf's to give the soil's food for the tree

4 0
3 years ago
Other questions:
  • Why are listening and speaking part of the Common Core and ELD Standards? Why is this particularly important for our ELD student
    14·1 answer
  • What is a method whereby new problems are solved based on the solutions from similar cases solved in the past?
    9·1 answer
  • Gps receivers are commonly used by individuals to determine their geographic location while hiking and to obtain driving directi
    5·1 answer
  • Which tab provides commands for the most commonly used elements in Word software?
    15·1 answer
  • What are the classifications of computer
    9·1 answer
  • Choose the correct term to complete the sentence.
    11·1 answer
  • My messaging system is messed up. It keeps saying I'm getting messages but then it says nothing new in my inbox. I'm confused- H
    15·2 answers
  • Who is willam afton from five nights at freddy
    13·2 answers
  • What is your favorite song? mine is "In the final"
    7·2 answers
  • What type of element addresses the recovery of critical information technology (it) assets, including systems, applications, dat
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!