Programming 2
Programming 2
50m
x 30m
Y z
40m
h) Using a function for each of the parts labeled X, Y and Z. Write a C program to calculate
the total area covered by the playground take pie to be 3.14 (7 marks)
a) Suppose x, y, z are simple Boolean expressions and all currently have the value FALSE.
How should the following expression evaluate? Show all your working (3 marks)
NOT X OR Y AND Z
b) Write the output of the following section of code (3 marks)
(i) Int x[5]= {5,2,7,5,8}
(ii) C,count=0;
(iii) For (c=0; c<5; c++)
(iv) If (x[c]>5)
(v) Count++;
(vi) Printf (“%d”,count);
c) Write a C program that accepts two integer values represented by a and b. Values
assigned to a should be equal to zero or greater than zero. Values assigned to b should be
less or equal to five. The program should ask the user to enter the values for a and b, if
the above conditions are met, the program should sum the two values i.e. a and b, divide
the sum by two and assign the results to a float variable called xmid. The program
should then display the value of xmid. (8 marks)
(i) The above programme will run with a warning, explain why? (3 marks)
(ii) Explain what should be done to remove the warning (3 marks)