UNIVERSITY OF WINDSOR 60-106-01 Fall 2006 QUIZ # 1 Examiner:Ritu Chaturvedi Dated : Oct 3rd, 2006. Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) Examination Period is : 1 hour Answer all questions in the bubble sheet provided to you. You must use a pencil to mark the answer. There are 25 multiple choice questions(questions 1-25) and 5 True/False questions(questions 26-30). Select only one answer for each question. Write your name and student number on the examination paper as well as the bubble sheet and submit both the bubble sheet and the examination paper before you leave the exam hall. Total Marks : 60 Total number of pages : 10 There may be more than one possible answer. Choose the best possible answer. Good Luck!!! 1
Multiple choice Questions : (25 x 2 = 50 marks) 1. A main memory with capacity 64 Kilobytes has approximately : a. 64 thousand cells b. 64 million cells c. 64 billion cells d. 64 cells 2. Given the equation y=ax 3 + 7, which of the following are correct C statements for this equation? a. y = a * x * x * x + 7; b. y = a * x * x * (x + 7); c. y = a * (x * x * x) + 7; d. y = (a * x ) * (x * x) + 7; 3. What arithmetic operators are on the same level of precedence as multiplication? a. + b. % c. / d. b and c e. a and b 4. What value gets stored in c after the following instructions are executed? int a,b,c; a = 4; b = 2; c = b * a / b % 2-1; a. 7 b. 7.5 c. -1 d. -2 2
5. The simple program segment for getting the sum of two numbers is. a. scanf( %d %d,num1, Num2); sum = Num1 + Num2; printf( %d,sum); b. scanf( %d%d,&num1,&num2); sum = Num1 + Num2; printf( %d,sum); c. scanf( %d %d,&num1, &Num2); average = (Num1 + Num2)/2; printf( %d,average); d. Read Num1, Num2; Sum = Num1 + Num2; Print Sum; 6. The correct statement which prints out the text Welcome, followed by a newline is : a. printf( Welcome\n ); b. printf(welcome, \n ); c. printf( Welcome\n ); d. printf(welcome\n); 7. The statement which prints out the value of the character variable letter, is a. printf(letter); b. printf( %c,&letter); c. printf( %d,&letter); d. printf( %c,letter); 3
8. Which one of the following expressions does not evaluate to 3? a. 2 + 6 % 5 b. 8-17 / 4 c. 6 * 5 / 10 d. 26-26 / 2-10 e. 8-5 9. Text enclosed in /* */ in a C program. a. gives instructions to the processor b. declares memory requirements c. makes files available d. causes a syntax error e. is a comment ignored by the C compiler 10. If num is a variable of type int and temp is a variable of type float, how could you correctly complete this function call? scanf("%f%d", ); a. num, temp b. &num, &temp c. temp, num d. &temp, &num 4
What data type would you use to represent in the computer for the following items in questions 11 and 12. 11. Number of students registered in 60-140 this semester a. int b. float c. char d. boolean 12. The average marks in quiz1 a. int b. float c. char d. boolean 13. A location in the computer s memory that may contain different values at various times throughout the execution of a program is called a. a. constant b. variable c. keyword d. entity 14. Which of the following statements is a call to function abc? a. call abc; b. abc; c. p = abc(q); d. void abc(void); 5
15. Which of the types listed below can be the data type of the result value returned by a user-defined function? a. int b. double c. char d. all of the above 16. The UNIX command on arc1.uwindsor.ca to compile a C program called a.c is: a. CC a.c b. cc a.c c. pico a.c d. a.out 17. Which of the following variable declarations are invalid? a. float num; b. int q; c. char plywood; d. all of the above 6
18. A diagram of the hierarchical organization of the subproblems of a solution is called. a. stepwise refinement b. divide and conquer c. a top-down approach d. function calls e. a structure chart 19. Keyword is used in a function header to indicate that a function does not return a value or to indicate that a function contains no parameters. a. int b. zero c. void d. Nothing 20. The statement(in C) that correctly defines an integer called sum is a. sum : integer; b. integer sum; c. int sum; d. sum int; 7
21. What value is assigned to q in the statement q = f(3, 3, 4); if f is defined as follows? int f(int a, int b, int c) { } return (a+b+c); a. 17 b. 10 c. 36 d. 0 22. The prototype for function f (defined in question 21) should be declared as : a. int f(int,int,int) b. int f(int,int,int); c. void f(int,int,int); d. void f(void); 8
Use the program below to answer questions 23,24 and 25. #include <stdio.h> void module1(int, int); void main(void){ int a, b,c; a=7; b=8; c=2; module1 (a,b); printf( %d %d \n,a, b); } //end of main void module1 (int a, int b){ a = a - 2; b = b + 2; } 23. What values of a gets printed when the above program is run? a. 0 b. 2 c. 8 d. 7 24. What values of b gets printed when the above program is run? a. 0 b. 2 c. 8 d. 7 9
25. Which statement in the above program is a call to function module1? a. module1(a,b); b. void module1(int a, int b){ c. void module1(int, int); d. Any of the above True or False (5 x 2 = 10 marks) a. True b. False 26. Formal parameters are specified in the function header. True 27. Actual parameters are specified in the function header. False 28. Statements in a high-level language are converted to statements in machine language by a loader. False 29. This assignment statement stores the sum of b and c in a: b + c = a; False 30. Because the following statement is a valid call to function wow, wow must be a void function. wow(x, y); True 10