Which of the following is NOT part of the CPU?

   A.   Program counter (PC)
   B.   Instruction register (IR)
   C.   Arithmetic logic unit (ALU)
   D.   Random access memory (RAM)


Which of the following statements is correct?

   A.   ASCII and EBCDIC are examples of standards for the assembly language.
   B.   A high-level programming language requires a specific translator in order for humans to understand.
   C.   We use an editor to compile the source code of a high-level programming language.
   D.   The result of the linking process is the .exe file.


Which of the following statements is incorrect?

   A. Functions are created primarily as the implementation of the object-oriented (OO)
      approach.
   B. Function headings without their bodies are called the function prototypes.
   C. Functions allow programmers to work on different problems simultaneously.
   D. Function definition can be placed before function main().


Which of the following statements is incorrect?

   A.   >> is called the stream extraction operator.
   B.   n is called the newline escape sequence.
   C.   The preprocessor command begins with a #.
   D.   char code;
        code = “B”;


Which of the following is not a standard C++ data type?

   A.   double
   B.   char
   C.   bool
   D.   int
Which of the following variables/identifiers are valid?

                    Variable / Identifier
           1.       Floating
           2.       ++Andalusia
           3.       MYFIRSTCPLUSPLUS
           4.       _4thFloor
           5.       Hard-disk
           6.       INCLUDE
           7.       Fungsi KU
           8.       <iostream>
           9.       Integer
           10.      Cmath

           A.    1, 3, 4, 6, 9, 10
           B.    1, 2, 3, 4, 5, 7, 8, 9
           C.    3, 4, 6, 8, 9, 10
           D.    1, 2, 3, 4, 6, 8, 9




                                            2/6
A



                          B




Rajah 1: Pemprosesan program C++.


Lengkapkan jadual berikut berdasarkan Rajah 1: Pemprosesan program C++. (5 markah)
Complete the following table based on Figure 1: Processing C++ program. (5 marks)

     Task        Step     Output                        Description
Editor            1     myprog.cpp     Typing/coding of C++ statements
Preprocessor      2          -         Accessing specified library / header files.
       A          3

Linker            4

         B        5           -




                                        3/6
Apakah output bagi aturcara C++ berikut? (5 markah)
What is the output of the following C++ program? (5 marks)

              #include <iostream>
              using namespace std;

              int mystery(int, int);
              int a = 100;

              void main()
              {
                int a = 33, b = 99;
                cout << "na = " << a << ", b = " << b << endl;

                  b = mystery (a, b);
                  cout << "na = " << a << ", b = " << b << endl;

                  a = mystery(2 * a - 3, b);
                  cout << "na = " << a << << endl;
              }

              int mystery (int x, int a)
              {
                 x = 200;
                 a = 100;

                  return a;
              }




                                         4/6
Tuliskan semula aturcara berikut dengan menunjukkan semua pembetulan. (5 markah)
Re-write the following code showing all corrections. (5 marks)

      #include<iostream>
      using namespace std;

      int main()
      {
           cout << “Masukkan bilangan jam bekerja “ ;
                 << “dan kadar bayaran :”
           cin >> bilJamKerja >> kadarBayaran;

             double bilJamKerja; kadarBayaran;
             gaji = bilJamKerja * kadarBayaran;




                                       5/6
Bina satu carta alir lengkap untuk aturcara berikut: Aturcara akan meminta agar pengguna
memasukkan satu nilai (dalam gram). Program akan menerima input dari pengguna dan
seterusnya menukarkannya kepada kilogram dan gram. Program akan memaparkan nilai-nilai asal
dan tukaran tersebut. Gunakan pembolehubah yang sesuai.
               Contoh input :      3500
               Contoh output :     3 kilogram 500 gram                     (5 markah)

Develop a complete flowchart for the following program: This program prompts the user to enter
a value (in gram). The program receives the input from the user and then converts it into kilogram
and gram. The program will display the original and converted values. Use appropriate variables.
               Sample input :       3500
               Sample output :      3 kilogram 500 gram                           (5 marks)




                                           6/6

C++ Question

  • 1.
    Which of thefollowing is NOT part of the CPU? A. Program counter (PC) B. Instruction register (IR) C. Arithmetic logic unit (ALU) D. Random access memory (RAM) Which of the following statements is correct? A. ASCII and EBCDIC are examples of standards for the assembly language. B. A high-level programming language requires a specific translator in order for humans to understand. C. We use an editor to compile the source code of a high-level programming language. D. The result of the linking process is the .exe file. Which of the following statements is incorrect? A. Functions are created primarily as the implementation of the object-oriented (OO) approach. B. Function headings without their bodies are called the function prototypes. C. Functions allow programmers to work on different problems simultaneously. D. Function definition can be placed before function main(). Which of the following statements is incorrect? A. >> is called the stream extraction operator. B. n is called the newline escape sequence. C. The preprocessor command begins with a #. D. char code; code = “B”; Which of the following is not a standard C++ data type? A. double B. char C. bool D. int
  • 2.
    Which of thefollowing variables/identifiers are valid? Variable / Identifier 1. Floating 2. ++Andalusia 3. MYFIRSTCPLUSPLUS 4. _4thFloor 5. Hard-disk 6. INCLUDE 7. Fungsi KU 8. <iostream> 9. Integer 10. Cmath A. 1, 3, 4, 6, 9, 10 B. 1, 2, 3, 4, 5, 7, 8, 9 C. 3, 4, 6, 8, 9, 10 D. 1, 2, 3, 4, 6, 8, 9 2/6
  • 3.
    A B Rajah 1: Pemprosesan program C++. Lengkapkan jadual berikut berdasarkan Rajah 1: Pemprosesan program C++. (5 markah) Complete the following table based on Figure 1: Processing C++ program. (5 marks) Task Step Output Description Editor 1 myprog.cpp Typing/coding of C++ statements Preprocessor 2 - Accessing specified library / header files. A 3 Linker 4 B 5 - 3/6
  • 4.
    Apakah output bagiaturcara C++ berikut? (5 markah) What is the output of the following C++ program? (5 marks) #include <iostream> using namespace std; int mystery(int, int); int a = 100; void main() { int a = 33, b = 99; cout << "na = " << a << ", b = " << b << endl; b = mystery (a, b); cout << "na = " << a << ", b = " << b << endl; a = mystery(2 * a - 3, b); cout << "na = " << a << << endl; } int mystery (int x, int a) { x = 200; a = 100; return a; } 4/6
  • 5.
    Tuliskan semula aturcaraberikut dengan menunjukkan semua pembetulan. (5 markah) Re-write the following code showing all corrections. (5 marks) #include<iostream> using namespace std; int main() { cout << “Masukkan bilangan jam bekerja “ ; << “dan kadar bayaran :” cin >> bilJamKerja >> kadarBayaran; double bilJamKerja; kadarBayaran; gaji = bilJamKerja * kadarBayaran; 5/6
  • 6.
    Bina satu cartaalir lengkap untuk aturcara berikut: Aturcara akan meminta agar pengguna memasukkan satu nilai (dalam gram). Program akan menerima input dari pengguna dan seterusnya menukarkannya kepada kilogram dan gram. Program akan memaparkan nilai-nilai asal dan tukaran tersebut. Gunakan pembolehubah yang sesuai. Contoh input : 3500 Contoh output : 3 kilogram 500 gram (5 markah) Develop a complete flowchart for the following program: This program prompts the user to enter a value (in gram). The program receives the input from the user and then converts it into kilogram and gram. The program will display the original and converted values. Use appropriate variables. Sample input : 3500 Sample output : 3 kilogram 500 gram (5 marks) 6/6