0% found this document useful (0 votes)
59 views4 pages

1 C++ Questions

Uploaded by

Tahpehs Phiri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views4 pages

1 C++ Questions

Uploaded by

Tahpehs Phiri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

Write the structure of a C++ program

[4]
2. (a) (i) Explain what is meant by
Variable
………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………… [2]
Constant
………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………… [2]
(ii) Using C++, declare a
Variable called age whose datatype is integer
………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………… [2]
Constant called president with the value Phiri
………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………… [2]

(b) List two C++ reserved words from the program structure in question (1)
………………………………………………………………………………………………………………… [1]
………………………………………………………………………………………………………………… [1]

(c) Outline three rules for naming variables in C++

Page 1 of 4
………………………………………………………………………………………………………………… [1]
………………………………………………………………………………………………………………… [1]
………………………………………………………………………………………………………………… [1]

3. What do the following symbols and or notations signify in C++?

(a) { ………………………………………………………………………………………………………….. [1]

(b) = ………………………………………………………………………………………………………….. [1]

(c) == ………………………………………………………………………………………………………… [1]

(d) / …………………………………………………………………………………………………………… [1]

(e) && ……………………………………………………………………………………………………….. [1]

(f) || ………………………………………………………………………………………………………….. [1]

(g) // ………………………………………………………………………………………………………….. [1]

(h) } …………………………………………………………………………………………………………... [1]

(i) != …………………………………………………………………………………………………………. [1]

4. Explain the meaning of


Bug
………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………. [2]
Debugging?
………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………. [2]

5. State the two types of errors in programming

Page 2 of 4
………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………… [2]

6. Explain the purpose of the following:


return 0?
………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………….. [2]
cin
………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………….. [2]
cout
………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………….. [2]

7. Study the C++ program below and answer the questions that follow:
L1: #include<iostream.h>
L2: int main() {
L3: decimal num1, num2;
L4: num1=10;
L5: num2=5;
L6: result=num1+num2
L7: cout<<”Addition of num 1 and 2 is “,num1/num2;
L8: result=num1-num2;
L9: cout<<”Subtraction of num 2 from num1 is “,num1+num2;
L10: return;
L11: }

(a) Identify the line number with errors and the error type in the above programs.
………………………………………………………………………………………………………………… [1]

Page 3 of 4
Error type …………………………………………………………………………………………………. [1]
………………………………………………………………………………………………………………… [1]
Error type …………………………………………………………………………………………………. [1]
………………………………………………………………………………………………………………… [1]
Error type …………………………………………………………………………………………………. [1]

(b) Correct the errors identified in (a)


…………………………………………………………………………………………………………….. [1]
…………………………………………………………………………………………………………….. [1]
…………………………………………………………………………………………………………….. [1]
8. State the name of a program that is used to translate a program written in C++ to
machine code.
………………………………………………………………………………………………………………….. [1]
9. (a) State two advantages of using low level languages rather than high level languages
when writing programs
1 …………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………… [1]
2 …………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………… [1]
(b) Give two examples of high level languages
………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………….. [2]
10. Mention three types of loops used in C++
1 …………………………………………………………………………………………………………….. [1]
2 …………………………………………………………………………………………………………….. [1]
3 …………………………………………………………………………………………………………….. [1]

Page 4 of 4

You might also like