0

How does the projects after each chapter in this app suppose to work?

For example in my c++ course chapter 3 "Data Types, Arrays, Pointers"there is a project (Ticket Office)that asks me to give a discount to the ticket price based on the lowest age of customer in a group which will be user inputed in an array by the app. but the lesson didn't show me how to print the max or min value from an array or maybe I am not realizing something. regardless A simple google search showed me how complex the process was https://www.geeksforgeeks.org/how-to-find-the-minimum-and-maximum-element-of-an-array-using-stl-in-c/ I apologize in advance if this project turns out to be simple and doesn't require the complexities I have shown.

23rd Sep 2021, 8:03 PM
Abdur Rahman
Abdur Rahman - avatar
6 Respuestas
+ 6
Abdur Rahman , i don't think it's too complicated: ▪︎there is always a group of 5 ages given as input ▪︎the regular ticket price for a 5 person group is 50 ▪︎find the smallest number in ages array (sort it or iterate through the array) ▪︎use the smallest number to calculate the discount as described in the task description happy coding and good success!
23rd Sep 2021, 8:53 PM
Lothar
Lothar - avatar
+ 4
Abdur Rahman , iterating over an array with for loop is a very basic task. have a look at the attached sample: https://code.sololearn.com/cIX4G93bW8M7/?ref=app
24th Sep 2021, 8:44 AM
Lothar
Lothar - avatar
+ 4
Abdur Rahman , the tutorials are just made to teach the very basics. for all rest use google or specially cpp reference.
24th Sep 2021, 12:11 PM
Lothar
Lothar - avatar
+ 1
Lothar tnx for the reply but the app hasnt showed me how to iterate or sort out the lowest value from the array.
23rd Sep 2021, 9:18 PM
Abdur Rahman
Abdur Rahman - avatar
+ 1
Nah it's not too complicated. Use a variable(min) pointing to the first value in the array. Loop through the array. If the subsequent values are smaller than our variable's value, make the smaller value the new value of our variable. I visited the link you shared and it was a little more complicated. You can do it in a much simpler way =)
24th Sep 2021, 2:01 AM
Rishi
Rishi - avatar
0
Lothar again tnx As u can see i never know that for loop can be done like this "for (int n : arr)" The app didnt show it to me. Regardless tnx
24th Sep 2021, 9:45 AM
Abdur Rahman
Abdur Rahman - avatar