Chat with us, powered by LiveChat 0) Random number generation. (50 pts) Often, computer scientists, statisticians, physicists, social - Writeedu

0) Random number generation. (50 pts) Often, computer scientists, statisticians, physicists, social

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.

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteEdu. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

Do you need help with this question?

Get assignment help from WriteEdu.com Paper Writing Website and forget about your problems.

WriteEdu provides custom & cheap essay writing 100% original, plagiarism free essays, assignments & dissertations.

With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.

Chat with us today! We are always waiting to answer all your questions.

Click here to Place your Order Now