All these questions are to be answered using the CSIF systems. If you use some other system, your answers may differ, and we will grade based on the CSIF systems.
mv x aWhat is the output of each of the following commands, and why?
Please do either of the two questions. You must pick one; you cannot do part of one and part of the other. In your submission, state which one you have done.
The function must have the following interface:
int fib(int n)Your function is to print the numbers on a single line with one blank separating numbers. Do not have any leading or trailing white spaces, and terminate the list of numbers with a newline.
/* your code goes here */
If n = 0, print a blank line (as the function is to print 0 Fibonacci numbers).
If the argument n is invalid, fib is to return 0. Otherwise, it is to return 1. You may assume we will call your with an integer argument, so you do not need to check the argument for being a non-integer. You do need to check that the integer is valid, i.e., non-negative.
The function you write must be stored in a file called “fib.c”.
Hint: There is a file that provides an interface (a main() routine) available on SmartSite; it is called “fibdriver.c”. If you download it and compile it with your function (see Compiling and Executing Your Program for details on how to do this), you can focus on writing the function. Also, the program “/home/bishop/ecs30/fib” is a copy of the program on the Gradebot that produces the output with which your program's output can be compared, so feel free to use it to test your program. It only runs on the CSIF.
The interface of your program must look exactly like this (your input is in bold; what the computer types is in normal font), if you are entering text from the keyboard:
Hello, there, my old friend!
How are you today?
I am very well, thank you!
First print the line number, with no leading space, then print a tab character and the word.
If there is no input, print nothing.
If you are reading input from a file (by redirecting it), just print the line numbers followed by the words; you do not need to print the input too.
The program you write must be stored in a file called “words.c”.
Hint: The program “/home/bishop/ecs30/fib” is a copy of the program on the Gradebot that produces the output with which your program's output can be compared, so feel free to use it to test your program. It only runs on the CSIF.
|You can also obtain a PDF version of this.||Version of October 19, 2015 at 11:34AM|