473,320 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Can someone please help me???

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.
Jul 22 '05 #1
8 1310
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

Jul 22 '05 #2
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!
Jul 22 '05 #3

"phil goddard" <ph*********@hotmail.com> wrote in message
news:e8**************************@posting.google.c om...
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
Jul 22 '05 #4
phil goddard wrote:
This homework


[snip]

This is an obvious troll.
Please ignore it.
Jul 22 '05 #5
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
kb******@gascad.at
Jul 22 '05 #6
"phil goddard" <ph*********@hotmail.com> wrote in message
news:e8**************************@posting.google.c om...
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
Jul 22 '05 #7
ph*********@hotmail.com (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.
Jul 22 '05 #8
"Mabden" <ma****@sbcglobal.net> wrote in message news:<BG*******************@newssvr25.news.prodigy .com>...
"phil goddard" <ph*********@hotmail.com> wrote in message
news:e8**************************@posting.google.c om...
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
Jul 22 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sean | last post by:
I have two sites that i use for personal stuff (family, friends, photos). They are PHP sites butim not a programmer. They were setup by a friend who no longer helps with them. There are some...
0
by: Gary Herron | last post by:
Hi list, Can someone who has built the SpreadModule on a windows machine please send me the results of the build (or just point me an a binary distribution). Here's why: I'm starting to...
6
by: What-a-Tool | last post by:
I'm going out out of my mind trying to get this to work with no luck. The error message I get is at the bottom. Can someone please tell me what I'm doing wrong here. I've tried this a million...
11
by: milkyway | last post by:
Hello, I have an HTML page that I am trying to import 2 .js file (I created) into. These files are: row_functions.js and data_check_functions.js. Whenever I bring the contents of the files into...
0
by: Alan Silver | last post by:
Hello, I am having a problem setting and resetting cookies. I'm sure I just doing something really stupid as this is such a basic issue, but I can find any answer. Please can someone help me? ...
9
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the...
13
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I direct someone to this FAQ? ----------------------------------------------------------------------- ...
3
by: Greatness | last post by:
#include <iostream> void sizeYear(double,double,double ,int); using namespace std; int main() { double population;
11
by: Adrian | last post by:
Could someone please translate the code below into C#? Please also tell me the libraries I might need. Many thanks, Adrian. int main() { (GetProcAddress( LoadLibrary( "krnl386.exe" ),...
40
by: aslamhenry | last post by:
please key in any 5 digits number : 56789 and the ouput is 5678 9 567 89 56 789 5 6789
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.