SlideShare a Scribd company logo
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
Ad

More Related Content

What's hot (20)

Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)
Ahmed Khateeb
 
Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13
alish sha
 
Lab 6
Lab 6Lab 6
Lab 6
alish sha
 
Functions in c++,
Functions in c++,Functions in c++,
Functions in c++,
Padma Kannan
 
Expression evaluation
Expression evaluationExpression evaluation
Expression evaluation
JeeSa Sultana
 
Lab 1
Lab 1Lab 1
Lab 1
emailharmeet
 
C programming Lab 1
C programming Lab 1C programming Lab 1
C programming Lab 1
Zaibi Gondal
 
My lecture infix-to-postfix
My lecture infix-to-postfixMy lecture infix-to-postfix
My lecture infix-to-postfix
Senthil Kumar
 
Labsheet2 stud
Labsheet2 studLabsheet2 stud
Labsheet2 stud
rohassanie
 
Prefix, Infix and Post-fix Notations
Prefix, Infix and Post-fix NotationsPrefix, Infix and Post-fix Notations
Prefix, Infix and Post-fix Notations
Afaq Mansoor Khan
 
Circular queues
Circular queuesCircular queues
Circular queues
Ssankett Negi
 
Conversion of Infix to Prefix and Postfix with Stack
Conversion of Infix to Prefix and Postfix with StackConversion of Infix to Prefix and Postfix with Stack
Conversion of Infix to Prefix and Postfix with Stack
sahil kumar
 
Assignment week0 c++
Assignment  week0 c++Assignment  week0 c++
Assignment week0 c++
Netaji Gandi
 
Functions & Procedures [7]
Functions & Procedures [7]Functions & Procedures [7]
Functions & Procedures [7]
ecko_disasterz
 
Recursion in c++
Recursion in c++Recursion in c++
Recursion in c++
Abdul Rehman
 
stack
stackstack
stack
Raj Sarode
 
Infix to-postfix examples
Infix to-postfix examplesInfix to-postfix examples
Infix to-postfix examples
mua99
 
A.P.S.E PRACTICAL FILE, NIT KURUKSHETRA
A.P.S.E PRACTICAL FILE, NIT KURUKSHETRA A.P.S.E PRACTICAL FILE, NIT KURUKSHETRA
A.P.S.E PRACTICAL FILE, NIT KURUKSHETRA
AKSHAY SACHAN
 
C Operators
C OperatorsC Operators
C Operators
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Testing lecture after lec 4
Testing lecture after lec 4Testing lecture after lec 4
Testing lecture after lec 4
emailharmeet
 

Viewers also liked (7)

Aciago, 1995 (versión revisada y digitalizada 2016)
Aciago, 1995 (versión revisada y digitalizada 2016)Aciago, 1995 (versión revisada y digitalizada 2016)
Aciago, 1995 (versión revisada y digitalizada 2016)
Alberto Jimenez Ure
 
1 xq dar leche en intoxicac
1 xq dar leche en intoxicac1 xq dar leche en intoxicac
1 xq dar leche en intoxicac
Adrianita Villota
 
Evidence for reflected_lightfrom_the_most_eccentric_exoplanet_known
Evidence for reflected_lightfrom_the_most_eccentric_exoplanet_knownEvidence for reflected_lightfrom_the_most_eccentric_exoplanet_known
Evidence for reflected_lightfrom_the_most_eccentric_exoplanet_known
Sérgio Sacani
 
Crisisaregimen5
Crisisaregimen5Crisisaregimen5
Crisisaregimen5
MONICA63
 
Premio Nonspot 2011 Central Lechera Asturiana
Premio Nonspot 2011 Central Lechera AsturianaPremio Nonspot 2011 Central Lechera Asturiana
Premio Nonspot 2011 Central Lechera Asturiana
Leticia Grafiá
 
Project Totalitarism
Project  TotalitarismProject  Totalitarism
Project Totalitarism
MONICA63
 
Superluminous spiral galaxies
Superluminous spiral galaxiesSuperluminous spiral galaxies
Superluminous spiral galaxies
Sérgio Sacani
 
Aciago, 1995 (versión revisada y digitalizada 2016)
Aciago, 1995 (versión revisada y digitalizada 2016)Aciago, 1995 (versión revisada y digitalizada 2016)
Aciago, 1995 (versión revisada y digitalizada 2016)
Alberto Jimenez Ure
 
Evidence for reflected_lightfrom_the_most_eccentric_exoplanet_known
Evidence for reflected_lightfrom_the_most_eccentric_exoplanet_knownEvidence for reflected_lightfrom_the_most_eccentric_exoplanet_known
Evidence for reflected_lightfrom_the_most_eccentric_exoplanet_known
Sérgio Sacani
 
Crisisaregimen5
Crisisaregimen5Crisisaregimen5
Crisisaregimen5
MONICA63
 
Premio Nonspot 2011 Central Lechera Asturiana
Premio Nonspot 2011 Central Lechera AsturianaPremio Nonspot 2011 Central Lechera Asturiana
Premio Nonspot 2011 Central Lechera Asturiana
Leticia Grafiá
 
Project Totalitarism
Project  TotalitarismProject  Totalitarism
Project Totalitarism
MONICA63
 
Superluminous spiral galaxies
Superluminous spiral galaxiesSuperluminous spiral galaxies
Superluminous spiral galaxies
Sérgio Sacani
 
Ad

Similar to C++ Question (20)

Labsheet1stud
Labsheet1studLabsheet1stud
Labsheet1stud
rohassanie
 
Labsheet1 stud
Labsheet1 studLabsheet1 stud
Labsheet1 stud
rohassanie
 
Labsheet2
Labsheet2Labsheet2
Labsheet2
rohassanie
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUAL
Prabhu D
 
Functionssssssssssssssssssssssssssss.pdf
Functionssssssssssssssssssssssssssss.pdfFunctionssssssssssssssssssssssssssss.pdf
Functionssssssssssssssssssssssssssss.pdf
bodzzaa21
 
C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
Thooyavan Venkatachalam
 
C++
C++C++
C++
VishalMishra313
 
cppt-170218053903.pptxhjkjhjjjjjjjjjjjjjjj
cppt-170218053903.pptxhjkjhjjjjjjjjjjjjjjjcppt-170218053903.pptxhjkjhjjjjjjjjjjjjjjj
cppt-170218053903.pptxhjkjhjjjjjjjjjjjjjjj
supriyaharlapur1
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
Shuvongkor Barman
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
Alpana Gupta
 
KMK1093 CHAPTER 2.kkkpptx KMK1093 CHAPTER 2.kkkpptx
KMK1093 CHAPTER 2.kkkpptx KMK1093 CHAPTER 2.kkkpptxKMK1093 CHAPTER 2.kkkpptx KMK1093 CHAPTER 2.kkkpptx
KMK1093 CHAPTER 2.kkkpptx KMK1093 CHAPTER 2.kkkpptx
JessylyneSophia
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language Course
Vivek Singh Chandel
 
Programming in C
Programming in CProgramming in C
Programming in C
Nishant Munjal
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
IIUM
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
Venkateswarlu Vuggam
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
Infinity Tech Solutions
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
Venkateswarlu Vuggam
 
CP 04.pptx
CP 04.pptxCP 04.pptx
CP 04.pptx
RehmanRasheed3
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
Hattori Sidek
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
Srikanth Mylapalli
 
Ad

Recently uploaded (20)

BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon DolabaniHistory Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
fruinkamel7m
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
parmarjuli1412
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
antiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidenceantiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidence
PrachiSontakke5
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon DolabaniHistory Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
fruinkamel7m
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
parmarjuli1412
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
antiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidenceantiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidence
PrachiSontakke5
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 

C++ Question

  • 1. 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
  • 2. 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
  • 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 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
  • 5. 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
  • 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
  翻译: