Re: Searching and sorting
You're going to need a struct or class representing the products and a container to hold them. I don't know if their use of the word "set" there is to be taken literally or not. Do you have the product class written yet and an appropriate container selected?
Re: Searching and sorting
no i dont actually, i didnt try that coz the question said i use a function..
Re: Searching and sorting
Quote:
Originally Posted by
shani09
no i dont actually, i didnt try that coz the question said i use a function..
Read the entire requirement. My post still stands.
Re: Searching and sorting
yeah i know you're right and i also know using a class or struct is a possible solution but i want help on how to use a function for the same solution.. that's what the question is really all about
Re: Searching and sorting
Quote:
Originally Posted by
shani09
yeah i know you're right and i also know using a class or struct is a possible solution but i want help on how to use a function for the same solution.. that's what the question is really all about
The two are unrelated concepts. You need a struct or class and a container full of them to pass to the function. The function "accepts a set of products names that are avilable in a stock; their unit prices and no of units sold from each stock in four periods in a year.
How do you think you're going to pass all that stuff to the function?
Re: Searching and sorting
i dont know that's why i'm asking.....
Re: Searching and sorting
Quote:
Originally Posted by
shani09
i dont know that's why i'm asking.....
And that's why I'm telling you. It's isn't really clear to me though if "Write down a function that accepts a set of products" means the function accepts the input from the user, or that's what gets passed to the function as an argument.
Re: Searching and sorting
okay then... i'll try to write it using structures...
Re: Searching and sorting
Although it was a past exam question i got from a friend