You are on page 1of 29
‘ SULIT UNIVERSITI TEKNIKAL MALAYSIA MELAKA PEPERIKSAAN AKHIR SEMESTER I SESI 2007/2008 FAKULTI TEKNOLOGI MAKLUMAT DAN KOMUNIKASI KOD MATAPELAJARAN : BITG 1113 MATA PELAJARAN : PENGATURCARAAN KOMPUTER PENYELARAS : PN MASHANUM OSMAN KURSUS : BENE / BENW/ BMFA/BENC/ BMEB / BMCA / BENT / BMFU / BMCS / BMCT/ BEKC / BEKM / BEKE / BMCD / BEKP MASA : 2 JAM 30 MINIT TARIKH : 6 NOVEMBER 2007 ARAHAN KEPADA CALON: 1. Kerlas soalan ini mengandungi TIGA() bahagian iaitu Bahagian A, Bahagian B dan Bahagian C. 2. Sila jawab SEMUA soalan dalam Bahagian A, Bahagian B dan Bahagian C di dalam buku soalan, Sila gunakan borang OMR untuk jawapan Bahagian A. 3. Kertas soalan ini mempunyai 2 versi bahasa. Versi Bahasa Inggeris bermula daripada muka surat 2 hingga 15, manakala Versi Bahasa Melayu bermula daripada muka surat 16 hingga 29. Sila jawab satu versi_ sahaja KERTAS SOALAN INI TERDIRI DARIPADA (29 ) MUKA SURAT SAHAJA. TERMASUK MUKA HADAPAN \ SULIT (BITG 1113) SULIT PART A - OBJECTIVE QUESTIONS (20 MARKS) PLEASE ANSWER ALL THE QUESTIONS 1. Each pass through a loop is called a/an A. enumeration B. iteration C. culmination D. pass through 2. A continue statement causes execution to skip to A. the return 0; statement B. the first statement after the loop C. the statement following the continue statement D. the next iteration of the loop 3. Ina group of nested loops, which loop is executed the most number of times? A. the outermost loop B. the innermost loop C. all loops are executed the same number of times D. cannot be determined without knowing the size of the loops 4. Which looping process is best used when the number of iterations is known? A. for while o 8 do-while 9 all looping processes require that the iterations be known, 5. What's wrong? while((i < 10) && (i > 24)) A. the logical operator && cannot be used in a test condition B. the while loop is an exit-condition loop C. the test condition is always false D. the test condition is always true SULIT (BITG 1113) SULIT 6. If there is more than one statement in the block of a for loop, which of the following must be placed at the beginning and the ending of the loop block? ‘A. parentheses () B. braces {} C. brackets {] D. arrows <> 7. Variables that are declared, but not initialized, contain A. blank spaces B. zeros C. "garbage" values D. nothing - they are empty Based on the following code, answer question number 8, 9 and 10. include using namespace std; int cube (int y); int main () t for (xe1; x<=10; xt) cout << cube (x) << endl; return 0; ) Ant cube (int y) { return y*y*y? > 8. State the scope for the variable x in main. A. Function scope B. File scope C. Global scope D. Local scope SULIT 10, i. 12. 13. (BITG 1113) SULIT What will be printed for the first iteration of the for loop A. 10 B. 8 C4 D. 1 What will be return by function cube for i = 4? A. 27 B. 64 c. 81 D. 12 Which of the following classes handlers file input? A. ofstream. B. ifstream C. instream D. inputfile How would you output to an open file named a_file? A. a_file.out ("output"); B. a_file="output"s C. a_file<<"output"; D. a_file.printé ("out Which of the following is the proper declaration of a pointer? Avint x7 Bint ex; C.ptr x: D. int *x; SULIT (BITG 1113) SULIT 14. Which of the following gives the memory address of integer variable a;? A.tar Boas Ca; D. address (a) 15. Which of the following is a properly defined struct?” A.struct (int a7) B.struct a_struct (int az} C.struct a_struct int a; D. struct a struct (int ar)s 16. Which of the following accesses a variable in structure *b? A.b->var; B.b.var; C.b-vary D. bovar; 17. Which of the following correctly declares an array? A.int anarray(10]; B.int anarvay; C, anarray(10}; D. array anarray[10]7 18. What is the index number of the last element of an array with 29 elements? A.29 B28 co D. Programmer-defined. SULIT (BITG 1113) SULIT 19, What number will the following program print if parameters are passed by value- result? 1. void flint x, int y) (+4; ys} 2, 3.int 4 ADs 5. printf("%d"i); 6. AO B.3 ci D.2 20. Which of the following gives the memory address of the first element in array foo, an array with 100 elements? A. f00 [0]; B. £00; C. £00; D. fo0[1]; SULIT BITG 1113) PART B -~ STRUCTURE QUESTIONS (50 MARKS) PLEASE ANSWER ALL THE QUESTIONS. QUESTION 1 (10 MARKS) SULIT a, Identify and name the type of loops represented by the following flowcharts in Figure | and Figure 2. O 0 [a= ona| q Tne | Print “Welcome toor igure 1: Flowchart (A) [ count=0 | (Count < 100) >> - FA8® True von 7 ‘weer / “eon? oO Figure 2 ; Flowchart (B) -T- (2 Marks) SULIT (BITG 1113) SULIT b. Construct a logical expression to represent each of the following conditions: i Score is greater than or equal to 80 but les than 90. (1 Mark) ii nis between 0 and 7 but not even. (1 Mark) €. Write a complete program for the following flowchart. (4 Marks) x. cout <<"x is "+x; intz=x+y3 coute<"z is "+75, Figure 3 : Flowchart d._ Show the output of the following programs. (2 Marks) i int i=l; while (i<10) if ( (itt) 42 == 0) cout << i << endl; ii int i = 07 while (i < 5) for (int j= 1s j>le { cout << je; cout << S##*” using namespace stdj void increment (inte x, ints y)i int main() ( int a, b; cin>>a>>b; inerement (a,b) ; cout<<"a is "< #include using namespace std; double power (double m, double n); ant main() { double m(10] = {2,4,6,8,10,3,5,7,9,11}5 double n, result; cin>>n; 2(a) cout<<"The result is "<

You might also like