1 C++ Questions
1 C++ Questions
[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]
Page 1 of 4
………………………………………………………………………………………………………………… [1]
………………………………………………………………………………………………………………… [1]
………………………………………………………………………………………………………………… [1]
Page 2 of 4
………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………… [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]
Page 4 of 4