CIS1057 Spring 2010 MIDTERM 1 Closed books, closed notes. The points per question are indicated next to the question. The total points for the exam are 105 (5) 1. List the basic hardware components of a computer system. (5) 2. What are microsecond, kilobyte, terabyte? (5) 3. What is a compiler? (5) 4. What is a byte and how many different values could be stored in it? (5) 5. Give examples of keywords and of identifiers (5) 6. Mark all the words that are not legal identifiers: Anna sam Joe's house#7 r2p2 (10) 7. Give an example of: (a) A compiler directive (b) A variable declaration (c) A Conditional Statement (d) A loop Statement (e) An I/O Statement (5) 8. What is a variable? Give at least an example. (10)10. Show how a for loop like for(e1; e2; e3) S can be replaced using a while loop. (5) 11. What is the value of the expression [ show how you arrive at the result ] 3 < 2 || (3 == 3) && 3 < 3 (5) 12. What is printed out by the following program fragment, assuming that x,y, and z are integer variables, with x and y initialized to 0 and z initialized to 1 [no indentation!]: if(x>0) if(y>0) z=2; else z=3; printf("z=%d\n",z); (5) 13. Given the variable int x complete the scanf statement below to initialize the variable x: scanf("%d", ); (5) 14. Describe all that you know about the following function prototype: int moo (double a, int n); [of course you do not know what moo does, but you know what it is, what are its parameters..] (10)15. I write the function void incr(int n) { n = n + 1; } then in my main program I write int x = 5; incr(x); printf("%d\n", x); What is printed out? and why. (10)16. What is the output of the following program fragment: printf("%d\n", (double)(20/3)); printf("%d\n", 10%3); printf("%d\n", (int)3.1416); printf("%f\n", ((double)20)/3); printf("%d\n", (int)3.1416); (10)17. Write a function that, given an integer X, returns 1 if and only if X is a multiple of 15, otherwise returns 0.