Your Perfect Assignment is Just a Click Away

We Write Custom Academic Papers

100% Original, Plagiarism Free, Customized to your instructions!

glass
pen
clip
papers
heaphones

Random number generation

Random number generation

0) Random number generation. (50 pts)
Often, computer scientists, statisticians, physicists, social scientists, and mathematicians need a list of random numbers. Political pundits also find lists of random numbers useful to provide ‘statistical’ evidence of their arguments.
Implement a tool to generate and print a sequence of 10 random numbers.  Each random number should be an integer in the range from
0 to 100, inclusive (that means both 0 and 100 should have a chance of appearing). I do not expect you to implement your own random number generator. I expect you to use the standard way of obtaining randomness in a secure fashion.
$ ./grand
56 77 91 2 33 40 72 100 6 2
Augment your program to take a command line parameter specifying how many random numbers to generate. That is, if grand is invoked by:
$ ./grand 4
it will output 4 random numbers from 0 to 100, inclusive. Make sure your program does something sensible if the supplied argument is not a valid integer. There should not be an arbitrarily imposed upper limit to this number (in other words, do not have an artificial cap on the value of the argument).
Since it is easy to forget how to use programs, it is often useful to provide a well-known command line switch (or parameter) that tells the user how to invoke the program. Augment your program to recognize two more command line arguments, ‘-h’ and ‘–help’ that prints out the usage information for the program. For example,
$ grand -h
and
$ grand –help
should output the following usage information:
grand [-h | –help]       : output this usage message.
grand [n]                 : print out n random integers in [0,100]
Finally, augment your program to print out its version. Don’t forget to add this usage case to your help dialog.
$ grand “version OR -v
grand-0.0.3
1) Functions and Recursion (50 pts)
Experiment with recursion. The Fibannaci sequence is a famous naturally recursive series of numbers whose ratio approaches the Golden Ratio.
f(n) = f(n-1) + f(n-2)
Implement a program named ‘fib’ that uses recursion to calculate and print the first n Fibannaci numbers, where ‘n’ is less than or equal to 30.
Usage:
fib [n]
For example, ‘fib 4’ should output:
fib(0) = 1
fib(1) = 1
fib(2) = 2
fib(3) = 3
fib(4) = 5
Modify your program so that providing the –target or -t option will print only the nth Fibannaci number.
$ ./fib –target 3
fib(3) = 3
Add the ability for your program to calculate the Fibannaci sequence iteratively rather than recursively. Output should not change. If you execute your program with the name ‘ifib’ then it performs the iterative calculation.  If it is executed via ‘rfib’ or ‘fib’ it performs the recursive method of calculating.
$ ./fib –target 3
fib(3) = 3
$ ./ifib –target 3
fib(3) = 3
$ ./rfib –target 3
fib(3) = 3
There is an example of how to accomplish this sort of test of the program name in C Programming Language, 2nd Edition, by Brian W. Kernighan, Dennis M. Ritchie textbook. You can search Google for an iterative version of Fibannaci, but be sure to cite where you found it in your README.
Note:
You may want to consider using GNU getopt library for processing command line options.

Order Solution Now

Our Service Charter

1. Professional & Expert Writers: Blackboard Experts only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Blackboard Experts are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Blackboard Experts is known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Blackboard Experts, we have put in place a team of experts who answer to all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.