



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Read instructions carefully Section A : Answer any TWO questions Section B: Answer any TWO questions Use separate answer books for Sections A and B All questions carry equal marks
Examiners: Prof. G. Hurley Dr. S. Foley Mr. D. O’Donovan Mr. F. O’Reilly
(b) (i) The program in Figure 1.1 makes use of a Default Argument. Indicate where the default argument is used and describe its purpose. [5 %]
(ii) A problem of ambiguity exists within this program. Explain why the problem exists and suggest how it may be corrected. #include
Figure 1.1 [6 %]
(c) Write the code necessary to overload the abs function such that it may be used as shown in Figure 1.2. int main() { cout << abs(-10) << ‘\n’; cout << abs(-11.0) << ‘\n’; cout << abs(-9L) << ‘\n,’; return 0; } Figure 1.2 [9 %]
(b) (i) Describe the exception mechanism used for error handling in C++. [3 %] (ii) Write code to illustrate how an int may be tested to see if it is within a valid range e.g. 10 – 100. Any value outside this range should be considered an error and an exception should be generated to deal with this circumstance. [5 %]
(c) How is memory dynamically allocated in C++? During your discussion, mention: o why malloc and free still exist but are no longer in use. o the distinction made between the dynamic allocation of a single and an array of classes giving code examples of each to illustrate your point. [8 %]
class derived: public base { int j; public: void set_j(int num) { j=num; } int get_j(){ return j; } };
Q4 (a) What are the main features of the C Calling Convention? Explain with examples what impacts this has when interfacing C and assembly language programs. [8 %]
(b) Given the following C++ fragment, write a routine AddDivide3 in x86 assembly which takes as parameters three integers and adds the first two parameters together before dividing the result by the third parameter, an integer division is sufficient.
extern AddDivide3(int X, int Y, int Z); int nNewX, nNewY, nNewZ; cin >> nNewX, nNewY, nNewZ; cout < “The Result is “ << AddDivide3(nNewX,nNewY,nNewZ) << endl; [11 %] (c) Compare and contrast the Graphical User Interface system as used in Windows and Unix, describing how they integrate with the operating system and their features. [6 %]
Q5 (a) The following Assembly code fragment of code uses BIOS Interrupt 10 with a value of 14h in ah to print out the single character in al. In this case ‘F’.
mov al, ‘F’ push ax mov ah, 14 int 10h pop ax
Write the x86 assembly code placing it in either a macro or procedure, which can be used to print out on one line the alphabet in reverse order and then move to the start of a new line. The ASCII codes 10 and 13 achieve a carriage-return and line feed. [9 %]
(b) Explain the concept of Memory Segmentation as it applies to the Intel x86 family of micro- processors, including what segments there are, how physical addresses can be calculated and the different registers used to support segmentation. Give one way that segments can be specified/identified in x86 assembly programs. [8 %]
(c) Draw a diagram showing the relationship of MFC and Windows 32 API/SDK with Windows and explain what they are and the functionality that they bring. In MFC what is the relationship between CWnd, CDialog and CView? [8 %]
Q6 (a) The following GUI was created using MS-Visual C++. Note no code has yet been written. What tools have been used to create this entire GUI and how do they work? What are the names given to component elements in this GUI? How are they identified in the program? [8 %]
(b)Write the program which will do the above interest calculation, section (a). Describe which tools need to be used and follow the steps which need to be done before writing this code. Provide the C++ code to read in the values from the GUI, perform the calculation and output the results above. [9 %]
(c) Describe the Graphics Subsystem available in Windows Programming. In particular you answer should explain Device Context, Device Drivers, Virtual Screen, Stock Objects, Viewport. [8 %]