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.
6 Answers
+ 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!
+ 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
+ 4
Abdur Rahman ,
the tutorials are just made to teach the very basics. for all rest use google or specially cpp reference.
+ 1
Lothar tnx for the reply but the app hasnt showed me how to iterate or sort out the lowest value from the array.
+ 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 =)
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