Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input begins with an integer indicating the number of integers that follow. You can assume that the list will have at least 2 integers and less than 20 integers.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 30SA
icon
Related questions
Question

help with this 

5.25 LAB: Two smallest numbers
Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input begins with an
integer indicating the number of integers that follow. You can assume that the list will have at least 2 integers and less than 20 integers.
Ex: If the input is:
5
10 5 3 21 2
the output is:
2 and 3
To achieve the above, first read the integers into an array.
Hint: Make sure to initialize the second smallest and smallest integers properly.
450336.2961436.qx3zqy7
LAB
ACTIVITY
1 #include <stdio.h>
2
3 int main(void) {
4
M6789
5
5.25.1: LAB: Two smallest numbers
8}
/* Type your code here. */
return 0;
main.c
Load default template...
Transcribed Image Text:5.25 LAB: Two smallest numbers Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input begins with an integer indicating the number of integers that follow. You can assume that the list will have at least 2 integers and less than 20 integers. Ex: If the input is: 5 10 5 3 21 2 the output is: 2 and 3 To achieve the above, first read the integers into an array. Hint: Make sure to initialize the second smallest and smallest integers properly. 450336.2961436.qx3zqy7 LAB ACTIVITY 1 #include <stdio.h> 2 3 int main(void) { 4 M6789 5 5.25.1: LAB: Two smallest numbers 8} /* Type your code here. */ return 0; main.c Load default template...
Latest submission - 4:33 PM PST on 02/06/23
Only show failing tests
1:Compare output
2:Compare output
Input
Your output Your program produced no output
Expected output
Input
3:Compare output
5
10 5 3 21 2
Input
2 and 3
Your output Your program produced no output
Expected output 1 and 2
4
1 2 31 15
5
1 8 91 23 7
Your output Your program produced no output
Expected output 1 and 7
Transcribed Image Text:Latest submission - 4:33 PM PST on 02/06/23 Only show failing tests 1:Compare output 2:Compare output Input Your output Your program produced no output Expected output Input 3:Compare output 5 10 5 3 21 2 Input 2 and 3 Your output Your program produced no output Expected output 1 and 2 4 1 2 31 15 5 1 8 91 23 7 Your output Your program produced no output Expected output 1 and 7
Expert Solution
Step 1

For the given problem, C program is to be written to give the smallest and second smallest numbers from the list of integer numbers. This will be done by using array as given. Array is implemented to store the elements with same type of data i.e. integer data in the given case.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage