Can someone please help me???

Discussion in 'C++' started by phil goddard, Jun 2, 2004.

  1. phil goddard

    phil goddard Guest

    This homework tests your understanding of pointers and how to use
    pointers with arrays and functions.
    What we want to do is find the next highest int in an array based on a
    given float, i.e. in the following example, based on the float 7.11 we
    want to find the 8.

    Tasks:
    1) Include all the required libraries and define a main().
    2) In main, define a
    a. float called myFloat, initialize it with 7.11
    b. one dimensional array called testArray[10]={1,2,3,4,5,6,7,8,9,10};
    c. an int called testArraySize=10
    d. call the function like so:

    3) Define two pointers fPtr and aPtr and initialize them to point to
    the float and the array
    4) Define another pointer called resultPtr, type int*, initialize it
    to NULL
    5) In main, call the function foo() like so:
    resultPtr = foo(fPtr, aPtr, testArraySize);
    6) Define a function foo() that
    a. receives a) a pointer to a float – myFloatPtr and b) a pointer to
    an integer myIntPtr and c) an integer myInt,
    b. and returns a pointer to an integer
    c. Using the pointer notation (i.e. NOT the [subscript] notation !!!),
    i. Use the myIntPtr, which points to the beginnigng of testArray (i.e.
    the 1) , and loop through the array until either the content of what
    myFloatPtr is pointing to (myFloat) is no longer less than the content
    of what myIntPtr is pointing to(condition 1), or until a counter
    (initialized with 0) is no longer less than myInt (the size of the
    array that was passed down – that makes sure you don't keep going past
    the array size) (condition 2).
    ii. While doing the comparison, you will need to cast the content of
    the myFloatPtr to an int to avoid warnings.
    iii. When condition 1 is met, return the content of myIntPtr, (the
    address of where the number in the array that was larger than the
    float is located, NOT what myIntPtr is pointing to!)
    iv. Else if condition 2 is met, return NULL.
    7) Back in main, test if the returned resultPtr is NULL, if yes,
    display "NOT FOUND", if not, display the content of what the pointer
    is pointing to, which should be 8.
    phil goddard, Jun 2, 2004
    #1
    1. Advertising

  2. phil goddard

    Mike Smith Guest

    phil goddard wrote:

    > This homework tests your understanding of pointers and how to use
    > pointers with arrays and functions.
    > What we want to do is find the next highest int in an array based on a
    > given float, i.e. in the following example, based on the float 7.11 we
    > want to find the 8.
    >
    > Tasks:


    What's there to help you with? You're told *exactly* what to do. Crack
    your damned textbook open.

    --
    Mike Smith
    Mike Smith, Jun 2, 2004
    #2
    1. Advertising

  3. phil goddard

    red floyd Guest

    phil goddard wrote:
    > [redacted]

    You forgot to give your instructor's email address, so we could mail the
    result to him along with the notification that you asked us to do your
    homework for you!
    red floyd, Jun 2, 2004
    #3
  4. phil goddard

    Mike Wahler Guest

    "phil goddard" <> wrote in message
    news:...
    > This homework tests your understanding of pointers and how to use
    > pointers with arrays and functions.
    > What we want to do is find the next highest int in an array based on a
    > given float, i.e. in the following example, based on the float 7.11 we
    > want to find the 8.


    I am certainly able (and willing) to help you with
    your assignment. But perhaps you need to research
    the meaning of the word 'help'. It does *not* mean
    'do it for me'.

    Show us your code, ask specific questions, and we'll help.

    -Mike
    Mike Wahler, Jun 3, 2004
    #4
  5. Troll Alert: Can someone please help me???

    phil goddard wrote:

    > This homework


    [snip]

    This is an obvious troll.
    Please ignore it.
    E. Robert Tisdale, Jun 3, 2004
    #5
  6. phil goddard wrote:
    >

    [snip]

    Help with what?
    This is one of the most detailed assignments I have
    ever seen. With detailed I don't mean: detailed in what
    to do, but detailed in how to do it.

    Why don't you take this cookbook and execute it?
    Start with item 1 and work your way towards the
    bottom.

    --
    Karl Heinz Buchegger
    Karl Heinz Buchegger, Jun 3, 2004
    #6
  7. phil goddard

    Mabden Guest

    "phil goddard" <> wrote in message
    news:...
    > This homework tests your understanding of pointers and how to use
    > pointers with arrays and functions.


    OMG, I hope I never have to work with someone who passed a class like this!

    --
    Mabden
    Mabden, Jun 3, 2004
    #7
  8. phil goddard

    Old Wolf Guest

    (phil goddard) wrote:

    > This homework tests your understanding of pointers and how to use
    > pointers with arrays and functions.
    > Tasks:
    > 1) Include all the required libraries and define a main().


    #define a main()

    > 2) In main, define a
    > a. float called myFloat,


    a { float called, myFloat,

    > initialize it with 7.11


    it = 7.11,

    > b. one dimensional array called testArray[10]={1,2,3,4,5,6,7,8,9,10};


    testArray[10]={1,2,3,4,5,6,7,8,9,10};

    > c. an int called testArraySize=10


    int testArraySize=10;

    > d. call the function like so:


    } so() {

    > 3) Define two pointers fPtr and aPtr and initialize them to point to
    > the float and the array


    char *fPtr = "the float and the array";
    char *aPtr = fPtr;

    > 4) Define another pointer called resultPtr,


    #define resultPtr

    > type int*,


    int*

    > initialize it to NULL


    it = NULL;

    Should all compile just fine. Now that I've given you a start,
    you should be able to finish it off yourself.
    Old Wolf, Jun 3, 2004
    #8
  9. phil goddard

    Guest

    "Mabden" <> wrote in message news:<BGAvc.78316$>...
    > "phil goddard" <> wrote in message
    > news:...
    > > This homework tests your understanding of pointers and how to use
    > > pointers with arrays and functions.

    >
    > OMG, I hope I never have to work with someone who passed a class like this!


    "Passed" is bad enough. Wait till you have to work with somebody
    who *FAILED* a class like this.
    Socks
    , Jun 3, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Teep
    Replies:
    7
    Views:
    439
    Ossewa
    Jul 27, 2006
  2. =?Utf-8?B?U2FuZHk=?=

    Help!! Can someone please check my code?

    =?Utf-8?B?U2FuZHk=?=, Apr 7, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    763
    =?Utf-8?B?U2FuZHk=?=
    Apr 9, 2005
  3. Alan Silver
    Replies:
    0
    Views:
    330
    Alan Silver
    Oct 6, 2005
  4. KK
    Replies:
    2
    Views:
    524
    Big Brian
    Oct 14, 2003
  5. shapper
    Replies:
    0
    Views:
    331
    shapper
    Dec 18, 2007
Loading...

Share This Page