Академический Документы
Профессиональный Документы
Культура Документы
(g) Using examples, Differentiate between assignment and equal operators in C ++.
(4 marks)
(h) Name two types of comments in C++ programming? Why are comments important?
(3 marks)
(i) It is very difficult to master and use machine language in programming. State two
scenarios when it is advisable to use a machine language over high level language and
why? (3 marks)
Page 1 of 3
Question Two (20 marks).
(a) Write a c++ program to calculate the KCSE average marks of a student for the
three compulsory subjects i.e. Mathematics, English and Kiswahili (7 Marks)
(b) Explain the output of the following C++ code snippet. (4 Marks)
int x, m, n;
m = 10;
n = 15;
x = ++m + n++;
cout<<”The values of m,n,x
are:”<<m”,”<<n”,”<<x<<”respectively.”<<endl;
(c) Write a C++ program find the area and the perimeter of a rectangle respectively.
(6 Marks)
(d) What is the first and the final values of i output by this loop. Explain
(3 Marks)
1,2,3,5,6,7
b) Using relevant diagrams, discuss the two main differences between the while and
the do…while structures. (4 Marks)
Page 2 of 3
Your lecturer for Programming II has recorded percentage marks for six students in
four continuous assessment tests as shown in the table below.
i) Write a C++ statement that would create a data type to store the above
values.
(2Marks)
ii) Write a C++ nprogram that would initialize the above values dynamically
and calculate the total mark and average score for each student.
(10 Marks)
Page 3 of 3