= zyBooks My library > COP 1220: Introduction to Programming in C home > 5.23: LAB: Two smallest numbers E zyBooks catal

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

= zyBooks My library > COP 1220: Introduction to Programming in C home > 5.23: LAB: Two smallest numbers E zyBooks catal

Post by answerhappygod »

Zybooks My Library Cop 1220 Introduction To Programming In C Home 5 23 Lab Two Smallest Numbers E Zybooks Catal 1
Zybooks My Library Cop 1220 Introduction To Programming In C Home 5 23 Lab Two Smallest Numbers E Zybooks Catal 1 (59.34 KiB) Viewed 22 times
Programming in C, can you fix what I have wrong?
= zyBooks My library > COP 1220: Introduction to Programming in C home > 5.23: LAB: Two smallest numbers E zyBooks catalog Help/FAQ Students: Section 5.23 is a part of 1 assignment: Final Programs Requirements: zyLab Due: 05/03/2022, 11:59 PM EDT 5.23 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. 363096 2422986.0x3y7 LAB ACTIVITY 5.23.1: LAB: TWO smallest numbers 0/10
1 #include <stdio.h> 2 #include <stdbool.h> LŨ Ở > 0 1 2 3 4 5 Hem N000 4 double calc_toll(int h, bool isM, bool isw) { 5 if (isw) { 6 if(is) { 7 if(h<7){ 8 return 1.05; 9 } 10 else{ 11 return 2.15; 12 } 13 } 14 else { 15 if(h<8) { 16 return 2.15; 17 } 18 else { 19 return 1.10; 20 } 21 } 22 } 23 else { 24 if (is) { 25 if(h<7){ 26 return 1.15; 27 } 28 else if(h<10){ 29 return 2.95; 30 } 31 else { 32 return 1.90; 33 } 34 } 35 else { 36 if (h<3){ 37 return 1.90; 38 } 39 else if(h<8){ 40 return 3.95; 41 } 42 else{ 43 return 1.40; 44 } 45 } 46 } 47} 48 49 int main() 50 { 51 printf("%.21f\n", calc_toll(8, true,false)); 52 printf("%.21f\n", calc_toll(1, false, false)); 53 printf("%.21f\n", calc_toll(3,false, true)); 54 printf("%.21f\n", calc_toll(5, true, true)); 55 56 return; 57 如归归归州职帕尔中配红印叫印加印
1: Compare output 0/4 Output differs. See highlights below. Special character legend Input 5 10 5 3 21 2 Your output 2.952 1.90 2.15- 1.052 Expected output 2 and 3 2. Compare output 0/3 Output differs. See highlights below. Special character legend Input 4 1 2 31 15 Your output 2.95- 1.90 2.15 1.052 Expected output 1 and 2 3: Compare output 0/3 Output differs. See highlights below. Special character legend Input 5 1 8 91 23 7 2.952 Your output 1.90 2.15 1.05 Expected output 1 and 7
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply