HNDIT 1103-Structured Programming Q1. (2007 First Semester Exam - Q 1)
HNDIT 1103-Structured Programming Q1. (2007 First Semester Exam - Q 1)
(d). Write a declaration (prototype) for a function called "testnumber( )" that has two arguments
and a reduce of type 'double’. The first argument is of the float and the second argument is
of type double with a default value of 10.5. (03 marks)
(e). What are the advantages of using functions? (03 marks)
(f). What would be the output from the following program fragment?
void change(void)
{
int x;
x = 1;
}
void main()
{
int x;
x = 0; change();
cout « x « endl;
}
(03 marks)
(g) Using an example describe how to use functions in a C++ program, (include function
declaration, function definition, and function calling)
(04 marks)
(Total 20 marks)
01. (a). What is a algorithm? List the characteristics of a good algorithm, (04 Marks)
(b) Identify the following symbols used in a flow chart. (02 Marks)
Start
Enter a number N
D 2
P TRUE
While E<N AND P=TRUE)
If N MOD D= 0) Then P-FALSE
DD+l
End While
If P=TRUE Then Output "SUCCESS"
Stop
(03 Marks)
(e) Draw a flowchart to find out the largest number of ten given numbers (04 Marks)
(f) Write a pseudocode equitant to the flowchart you have drawn in e). (04 Marks)
[Total 20 marks]
Q3. ( 2010 First Semester Exam - Q 1)
(i) Briefly describe what is an algorithm, flowchart and pseudo code? (03 marks)
(ii) Which graphical notations are usually used in a flowchart for begin/end, process, selection
and input/output? (02 marks)
(iii) Use flowchart and pseudocode to explain the terms sequence, selection, and iteration in
structured programming? (03 marks)
(iv) An unstructured algorithm for finding the Greatest Common Divisor (GCD) of two given
(positive) numbers is given below.
Find the GCD of 18 and 30 by using the above algorithm. Clearly show your execution.
(02 marks)
(v) Draw a structured flow chart to output the GCD of two given numbers based on the above
algorithm. (05 marks)
(vi) Write a structured pseudo code to output the GCD of two given numbers based on the above
algorithm. (05 marks)
(Total 20 marks)