quota -v
to see how much quota you have allotted and
how much you are using.
Run du -sh
in your cisc105 directory to show which
directories consume the most space.
You will demonstrate your use of UNIX at the end of this assignment as well.
Two things to keep in mind:
Label the value at each increment. (Notice how you can use those simple functions to write a pretty cool program!)
Add a user menu to print either the sine or cosine function.
Example Output:
0.000 0.296 ******** 0.565 **************** 0.783 *********************** 0.932 *************************** 0.997 ***************************** 0.974 ***************************** 0.863 ************************* 0.675 ******************** 0.427 ************ 0.141 **** -0.158 **** -0.443 ************* -0.688 ******************** -0.872 ************************** -0.978 ***************************** -0.996 ***************************** -0.926 *************************** -0.773 *********************** -0.551 **************** -0.279 ******** 0.017 0.312 ********* 0.578 *****************
rand()
, with no parameters, returns a
pseudo-random integer on successive calls in the same program. Write a
simple program that prints five calls to rand
so you can
see how it works.
You can use the mod operator to restrict the range of integers that are produced by calls to rand. (Think about how to implement that.) Then you can shift the whole range to the left or right using addition.
Write a function that takes as parameters a high and low value
and then produces a random integer in that range (inclusive). Put a
call to the function in main
, add scanf and a loop so the
user can generate as many random numbers as he wishes, each in a
different range. Add a prototype if you haven't already.
Now make your output more random: add the statement srand(
time(NULL) )
to the beginning of your main. Can you see that
this is just a function call inside a function call? What do you think
it does? Explain in your comments (the answer is hidden in your
text).
Example Run:
Enter the number of random numbers to generate in a range (or -1 to exit): 10 Enter the low and high values in the range: 1 10 Your random numbers are 10 7 5 1 2 2 3 8 5 7 Enter the number of random numbers to generate in a range (or -1 to exit): -1 Good bye!
Example run:
Enter 10 numbers: 2 5 3 1 1 1 0 -1 1 1 The running sum is 2 7 10 11 12 13 13 12 13 14
void printHistogram( int data[], int dataSize );
Write the function that goes with this prototype. (Recall why the size of the array is a parameter.) It should print each element of the array on a different line. Test it by creating three arrays of different sizes, and call the function from main() for each.
Example Run (only one array):
Enter the range: 5 10 6: ****** 9: ********* 10: ********** 7: ******* 6: ******
void printArray( int data[][10], int dataSize );
After that is working, add a second array that is 20x10, fill and print it.
doubles
and returns the product of the elements. Declare three arrays of different
sizes, initialize, print (perhaps using a function you wrote earlier in
the lab), and show the products.
You should have a total of 9 programs named lab05.1.c to lab05.9.c. Make a single script file (see lab00 for the instructions) where you cat, compile, and run each one in its final form (if it didn't compile, don't run it in the script - mark the place in the printed script file with a marker so it stands out).
Note: Cat, compile, and run each program in order! Do not cat all programs, then compile, etc.
Execute your program multiple times to show that you tested the program well.
Run du -sh *
in your cisc105 directory and identify
which directory takes up the most space. Use | grep M
if
you get too much data to sort through.