Monday, July 27, 2009

Help with C++ array program?!?!?

Have a function fill an array with random numbers in the range 1-99.


Have it done with a function called Fill.


The array will contain 50 numbers.


Print the list.


Ask for the number to be searched for in the list.


Send the array and the “target” value into another function called Find.


Print out if the number was found in the list.





Hints: have randomize() at start of the program. And #include%26lt;stdlib.h%26gt;


In a loop use num[x]=random(99)+1;


You must have an #include%26lt;stdlib.h%26gt; for random.


In your Find function send in the array and target.


Have local variable, call it flag, set to –1. If the target is found, change flag to 1.


Return flag. If the return is –1, cout “Not found”, else, cout “Found”





If you are clever have it print WHERE it found target; the number location (you will need a reference parameter.)

Help with C++ array program?!?!?
Sounds like a fun homework assignment! What exactly are you having problems with? Have you tried anything yourself yet?
Reply:what is your question?
Reply:What exactly do you want to know?


No comments:

Post a Comment