UFMFN7-15-1 January 2016
UFMFN7-15-1 January 2016
UFMFN7-15-1 January 2016
Technology
Academic Year: 15/16
None
University approved Calculator Yes
UFMFN7-15-1 Page 1 of 8
Instructions to Candidates:
The diagram below shows a state transition diagram used to design the embedded
software control system for a simple microwave oven.
Using the state transition diagram as a starting point, and making any reasonable
assumptions, devise a pseudocode solution for the operation of the oven control
software (hint: you should use the SWITCH/CASE statement).
[20 marks]
UFMFN7-15-1 Page 2 of 8
Question 2. [20 marks]
(a)
(b)
The diagram below shows part of a structure chart for the design of an “intelligent”
washing machine which varies washing time with the characteristics of the washing
load.
You should take care to ensure that the syntax of your C function, including
parameters, is correct.
[10 marks]
UFMFN7-15-1 Page 3 of 8
Question 3. [10 marks]
i) State two advantages of using #define in this context and explain your
answers.
ii) State one more example of a pre-processor directive used in C-programs.
[6 marks]
#include <stdio.h>
int main(void)
{
int num, i;
int sum=0
printf("Please enter a number: ");
scanf("%d", &num);
for (i=1; i <= num; i++)
{
sum = sum + i;
printf(%d\n, sum);
}
return 0;
}
i) The above code will fail to compile due to syntax errors. Identify the syntax
errors and correct the code above.
ii) What is the output of running the corrected program when the value
entered for num is 3?
[4 marks]
UFMFN7-15-1 Page 4 of 8
Question 4. [10 marks]
start
Initialise variables
Product=1; i=1
false
Increment i i < 5? print
by 1 product
true
Product = end
Product*i;
[3 marks]
#include <stdio.h>
#include <stdlib.h>
int main(void){
int product=1;
int i=1;
return 0;
} (Question 4 continued overleaf…….)
UFMFN7-15-1 Page 5 of 8
Complete the program so that it achieves the task shown in the flowchart.
[5 marks]
[2 marks]
(a)
Explain what is meant by an index to an array. For a C language array of size N,
what are valid indices?
Is a floating point value valid for an array index? If not, why not?
[4 marks]
int Array1[] = {12, 23, 2, 14, 50, 30, 20, 10, 22};
int Array2[] = {10, 20, 30, 40, 50};
ii) Write a for loop that allows you to add Array1 with Array2 such
that only even indices of Array1 are used and all indices of Array2
are used. Results of the addition are stored in Array3.
[6 marks]
UFMFN7-15-1 Page 6 of 8
Question 6. [10 marks].
(a)
Explain, using examples, the difference between a local variable and a global
variable in a C-language program.
[4 marks]
*ptr = 2;
ii) Write a printf() statement that allows the value pointed by ptr to
be displayed on screen.
iii) What value does the variable val contain after executing the above
statements?
[6 marks]
UFMFN7-15-1 Page 7 of 8
Question 7. [10 marks]
[10 marks]
(a) Explain the difference between the verification and the validation of a program.
[4 marks]
(b) The following rules have been taken from a standards document. Briefly state
why you think each rule has been defined.
9.1 All automatic variables should be assigned a value before being used.
[6 marks]
UFMFN7-15-1 Page 8 of 8