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<stdlib.h>
In a loop use num[x]=random(99)+1;
You must have an #include<stdlib.h> 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.)
If your
project doesn’t work, look for the part that you didn’t think was
important. Again and again, the impossible problem is solved when
we see that the problem is only a tough decision waiting to be made.
-Arthur
Bloch
-Robert Schuller