You are on page 1of 13
CONFIDENTIAL, CSIJUN 2014/68C425 UNIVERSITI TEKNOLOGI MARA FINAL EXAMINATION COURSE : INTRODUCTION TO COMPUTER PROGRAMMING COURSE CODE : CSC425 EXAMINATION : JUNE 2014 TIME : 3HOURS INSTRUCTIONS TO CANDIDATES 1 This question paper consists of three (3) parts: PART A (15 Questions) PART B (5 Questions) PART C (2 Questions) 2. Answer ALL questions from all three (3) parts i) Answer PART A in the Objective Answer Sheet. ii) Answer PART B and PART C in the Answer Booklet. Start each answer on a new page. 3, Do not bring any material into the examination room unless permission is given by the invigilator, 4, Please check to make sure that this examination pack consists of : i) the Question Paper an Answer Booklet — provided by the Faculty ii) an Objective Answer Sheet — provided by the Faculty DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO This examination paper consists of 73 printed pages © Hak Cipta Universiti Teknologi MARA CONFIDENTIAL CONFIDENTIAL 2 CSIJUN 2014/C8C425 PART A (30 MARKS) a Aset of value and a set of operation can be applied to specific type is called a_. ‘A) reserve words B) keywords C) syntax D) data type Which of the following is classified as high level programming language? A) Assembly language 8) Machine Language C) Ce D) Flowchart A process of identifying and fixing the error(s) in a source code is called _. A) compiling 8) coding C) debugging D) designing In the counter-controlled loop, the counter variable must be declare and initialize a variable named population to 0. A) double population; B) double population = 0; C) long population; D) long population = 0; (© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL, CONFIDENTIAL 3 CSIJUN 2014/68C425 6. Which of the following statements declares a constant called vot ingage which value is 21? A) const votingAge = 21; B) const int votingage; C) const int votingAge = 21; D) int votingage = 21; 7. Given the following code fragment: int i= 2; while (i { -1) cout << “Hello\n”; atest) How many times the output statement will be executed? ‘A) Infinite loop B) 0 c) 4 D) 3 8. Given the following code fragment: while(inValue != 999) ( statement (s); ) bo The role of “999" is known as __. A) sentinel Value B) input value C) counter variable value D) limit variable (© Hak Cipta Universiti Teknolog! MARA, CONFIDENTIAL CONFIDENTIAL, 4 CSIJUN 2014/¢8C425 9, Whats the output of the following code segment if the input values are 4,6,77 int num; cin >> num; while(num % 2 == 0) ( cout << num +1 <> num; ) | A) 8) 6 7 56 7] c) 45677 D) 45677 10. Which of the following statements declares a string called name that is able to hold up to 19 characters? A) char name; B) char name = 20; C) char name [20]; D) char(20] name; 11. Given the following array declaration: double moistLevel [8]; Which of the following statements is TRUE pertaining to the array? A) The array can holds 8 floating-point values. B) The first element of the array is refered to as moistLevel [1] C) The last element of the array is refered to as moistLevel (8) D) The array was initializaed with 0 .0 ‘© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL CONFIDENTIAL, 5 CSIJUN 2014/¢8C425 12. What is the output of the following code fragment if user enters 99? cin >> num; if(num < 0) cout << "TRUE\n"; else if(num > 0) cout << "FALSE\n"; else cout << " ULL\n" )while(num != 99); A) TRUE B) FALSE ©) nuLL D) No output 13. Given the following array declaration: float fscore(SIZE] = (45.8, 68.3, 75.4, 88.0, 23.5, 100.0, 39.5, 50.5, 75.0,88.3}; Which of the following statements is TRUE to describe about an array? i. The size of the array is 10. ii. The identifier called st2B must be declared as constant ii, The array is named as fscore iv. The index of the last element is 10 A) iandiv B) iiand ii C) ii, itand ii D) ii, iii and iv © Hak Cipta Universiti Teknologi MARA CONFIDENTIAL CONFIDENTIAL, 6 CSIJUN 20141080425 14. 15. Given the following code fragment: int number; cin >> number; if (functionX (number) == 1) cout << “This is an odd number\n"; else cout << “This is an even number\n”; Which of the following the most suitable function prototype for the functionx()? A) int functionx (); B) void functionx (float); C) void functionx (int); D) int functionx (int); Given the following function definition: float avgvalue(float vil, float v2, float v2) { return ((vl + v2 + v3) / 3); ) Which of the following function call can be used to calculate the average of three numbers and assign it the variable avg? A) float avgvalue(45.0, 67.0, 89.0); B) avg = avgValue (45.0, 67.0, 89.0); C) avgvalue(45.0, 67.0, 89.0); D) avg = float avgValue (45, 67.0, 89.0); (© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL, CONFIDENTIAL 7 CSIJUN 2014/¢8C425 PART B (50 MARKS) QUESTION 1 a) Briefly explain the problem-solving process. (2 marks) b) Explain the use of an assembler and a compiler. (2 marks) c) _Indicate whether the following statements are TRUE or FALSE. i) Machine language is a language made up of binary-coded instructions that use directly by the computer. ii) Source code is a program written in a language. level programming il) Java and C are the examples of the low-level programming language. iv) During execution phase, the computer runs the compiler program and produces the object program. v) Flowchart is a fictional representation of an orderly step by step solution to a problem. vi) Run-time logic error occurs during the execution of the program. (6 marks) (© Hak Cipta Universiti Toknolog! MARA, CONFIDENTIAL CONFIDENTIAL, 8 CSIJUN 2014/08C425 QUESTION 2 Draw a flowchart OR outline a pseudocode to solve the following problem. Traders Hotel is intoducing the new room rate for the year 2014: Types of Room Room Rate (RMinight) Super Luxury (S) 2500 Luxury (U) 1500 [Deluxe (D) 750 In order to calculate the charges, user is req ¢d to input: © Types of room * The number of days customer stay in the hotel 6% government tax will be added to the charges. Once the total charges (Inclusive of government tax) are calculated, display the total charges to the user. Your program should repeat the process for a few number of times until user enters 'N’ to terminate the program. (10 marks) (© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL CONFIDENTIAL, 9 CSIJUN 2014/C8C425 QUESTION 3 a) Write a C++ statement for each of the following arithmetic expression. dy i) y= +a) (2 marks) b) Evaluate each of the following expressions. i) 5047/24 (5 +3) j)4+3>7668+1<10 == (2 marks) ©) Rewrite the main function to conform to good programming practice. int main ( Mu cout << "Reading source code is much easier \n"; cout << "if it is indented properly\n"; return 0;} (2 marks) 4) Declare the following variables with suitable data tyoe for each of the following items. i) An average score ii) Types of gender (2 marks) (© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL CONFIDENTIAL 10 QUESTION 4 a) Identity the output for each of the following code fragments. i) char testVar = 'R'? switch (testVar) { case 'G': cout << "Brommm\n"; break; case 'R': cout << "Opsss\n"; case 'Y': cout << "Kabommm\n"; break; default : cout << "Safe\n"; }//end switch float num = 0.5; int i = 6; while (i > 0) ( if(i % 3 != 0) cout << num << ' 1; else cout << num << endl; int arr[4] = (1,0,1,1)7 int i = 0, temp; temp = arr(0]; while (i < 3) © geet) = aretieni: atts }//end while arr(i] = temp; cout << arr(0) << ' ' << arr[1] <

You might also like