LAST Name FIRST Name Points... 20 points total. 1. Random questions about C (1a) 1 point. In C, what function is used to open a file? (1b) 1 point. Give code to declare an array of 50 C strings. (1c) 1 point. What is the largest value that can be stored in a 1-byte unsigned integer? (1d) 1 point. In C, what are the integer values for true and false? (1e) 2 points. Give C code that will repeat the following forever: ask the user for an integer, then print the value of that integer squared. 2. 4 points. Give C code Give correct C code to ask the user for a word, read the word using scanf, and then print the ASCII code of each letter in the word. If they typed bad, the program would print 98 97 100 3. Think... (3a) 2 points. Suppose you have n items to store and can use either a sorted array, unsorted array, or hash table. For each choice, say what the running time of insert and lookup would be. Assume the hash table behaves well. Insert Lookup ----------------------------------------------------------------- Sorted array: Unsorted array: Hash table: (3b) 1 point. Suppose your computer can do 1 billion operations per second. What is the largest number of items that could be stored in a sorted array and still have lookups take at most 1 second? (3c) 1 point. Suppose your computer can do 1 billion operations per second, and you want to sort 1 million items. The running time of selection sort is n*n / 2. How many seconds does it take to use selection sort to sort the 1 million items? (3d) 1 point. Evaluate the following (assume numbers are written in decimal) 42 & 35 42 | 35 42 ^ 35 42 && 35 42 || 35 4. 5 points. Math/memorize (4a) 50 + 51 + 51 + ... + 100 = Hint: (1 + 2 + ... + 100) - (1 + 2 + ... + 49) (4b) 1 + 10 + 100 + ... + 10^9 = (4c) log(8^3) = 3 * log(2^3) = 3 * 3 * log(2) = 9 Note: log's are base 2 in CS courses unless otherwise stated. (4d) How many BYTES in 3 megabytes? (4e) (13^5 / 13^3)^7 = 5. On computer part of the exam... * In your handin directory, create a directory called exam3 * In the exam3 directory, create a text file called exam3.txt A) 5 points: In exam3.txt, put answers to the on-paper questions if you think you got any of them wrong, but then know the correct answer by using the computer. The exam is exam3.txt in the class code directory. You get full credit if you fix at least 3 mistakes from the paper test. B) 5 points: For question (2), create a program called print_ascii.c with the program. Compile it into a file called pa. A correct working version is called print_ascii in the class code directory. NOTE: CORRECTION, on the paper it said question (1e). C) 5 points: Create a program called sorted.c that reads floating point numbers from standard input as long as (scanf("%f",&num) == 1). After reading in all the numbers, the program prints either "Numbers were in sorted order" or "Numbers were NOT in sorted order". Compile it into a file called s. A correct working version is called sorted in the class code directory. Grading on part A... * no mistakes fixed: 0/5 * at least one mistake fixed: 3/5 * at least two mistakes fixed: 4/5 * at least three mistakes fixed: 5/5 * if you didn't have many mistakes to fix... 4/5 if you fixed at least half of them 5/5 if you fixed at least 75% of them problem doesn't count for any points if you just didn't have any mistakes on the paper part Grading on parts B and C... * Some part of the output is correct: 4/5 * Compiles, runs, is heading in the right direction: 3/5 * Compiles, runs, but isn't really on the right track: 1/5 * Doesn't compile: 1/5 * Couldn't find your file: 0/5