CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2010
    Posts
    14

    Smile Searching and sorting

    Hello, any help of any kind will be very much appreciated.
    I've done the other part of the question but my code is actually useless without this first part

    here it is:
    "Write down a function that 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. Assume that there can be 100 different items in the stock.Then find the amount of sales of each product and the total amount of sales..."

    The other part involves sorting and searching for specific products info but i'm okay with that. I could also use structures but i'm asked to use functions and i need some help with that.

    Thanks..

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    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?

  3. #3
    Join Date
    Apr 2010
    Posts
    14

    Re: Searching and sorting

    no i dont actually, i didnt try that coz the question said i use a function..

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Searching and sorting

    Quote Originally Posted by shani09 View Post
    no i dont actually, i didnt try that coz the question said i use a function..
    Read the entire requirement. My post still stands.

  5. #5
    Join Date
    Apr 2010
    Posts
    14

    Smile 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

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Searching and sorting

    Quote Originally Posted by shani09 View Post
    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?

  7. #7
    Join Date
    Apr 2010
    Posts
    14

    Re: Searching and sorting

    i dont know that's why i'm asking.....

  8. #8
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Searching and sorting

    Quote Originally Posted by shani09 View Post
    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.

  9. #9
    Join Date
    Apr 2010
    Posts
    14

    Re: Searching and sorting

    okay then... i'll try to write it using structures...

  10. #10
    Join Date
    Apr 2010
    Posts
    14

    Re: Searching and sorting

    Although it was a past exam question i got from a friend

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured