FINAL TERM EXAMINATION
SEMESTER FALL 2005
CS508-Modern Programming Languages
|Total Marks: 100 Duration: 3 Days|
Maximum Time Allowed: 3 Days
Please read the following instructions carefully before attempting any question:
The examination mode for the cs508 final term examination is take home examination, which mean that you are allowed to take your examination papers to your home or computer labs and complete it using all available resources. Followings are the instructions for doing the take home examination.
For Teacher’s use only
Question No: 1
| Consider the following Code written in C.
int a = 0;
int f(int x, int y)
return (a = x + 1);
int g(int *x)
return (*x = a + 2);
w = double(a) + f(a, g(&a))/g(&a);
printf (“w is %f”, w);
On some different important commercial compilers, the values found for the variable w were 5.6, 4.5, and 7.5. Furthermore, this last value changed to 2.5 when the expression to compute w was changed to:
w = f(a, g(&a))/g(&a) + double(a);
None of this is an error by the compiler writer!
(a) Give a justification for each one of these values.
(b) Would Java have the same kind of problem? Why or why not. Justify.
Question No: 2
| Compare C# and Java and highlight at least five differences. Then critically compare these features and argue why one design is better than the other.
|Question No: 3 Marks: 20|
|(a) Write a Prolog description of your family tree (based only on facts), going back to your grandparents and including all descendents (males and females). The facts should include the gender of a person and relationship of every person with every other person.(b) Write a set of rules for family relationships, including all relationships from grandparents through two generations. Now add these to the facts of part (a), and eliminate all the facts except the gender and parent-child relationship. You should still be able to establish the relationship of any person with any other person in your family.
Question No: 4
| Compare weak and strong typing. Argue why it is OK to have weak typing in scripting languages but not in other general purpose languages such as Java and C++.
Question No: 5
| Consider the following 5 binding times:
(1) language design time
(2) program writing time
(3) compile time
(4) load time
(5) run time
Give at least one example of each of the above for the following languages:
CS201 Introduction to Programming
Final Term Examination – February 2005
Time Allowed: 150 Minutes
Please read the following instructions carefully before attempting any of the uestions:
1. Attempt all questions. Marks are written adjacent to each question. 2. Do not ask any questions about the contents of this examination from anyone.
a. If you think that there is something wrong with any of the questions, attempt it to the best of your understanding.
b. If you believe that some essential piece of information is missing, make an appropriate assumption and use it to solve the problem.
c. Write all steps, missing steps may lead to deduction of marks. d. All coding questions should be answered using the C ++ syntax.
You are allowed to use the Dev-C++ compiler to write and test your code. If you do so please remember to copy and paste your code into the examination solution area.
(Do NOT share your code; your colleague could get higher marks than you!!)
**WARNING: Please note that Virtual University takes serious note of unfair means. Anyone found involved in cheating will get an `F` grade in this course.
|Total Marks: 100||Total|
|Question No. 1||Marks : 2|
A function declaration has the same relationship to a function definition that
1 a class definition has to an object definition
2 an object declaration has to an object
3 a variable has to a variable declaration
4 a variable declaration has to the variable itself
5 they have no relationship
Question No. 2 Marks : 12
Write a function to overload subtraction operator for Class Order, which you created in previous question. The class has following attributes/ data members
Write the main () to call the – operator and print the result also. This operator should subtract the items of one object from the other.
Question No. 3 Marks : 4
What is the difference between an array and a structure?
Question No. 4 Marks : 2
When we write a class template the first line must be:
1 template < class class_type>
2 template < class data_type>
3 template < class T >, Here T can be replaced with any name but it is preferable.
4 class class-name()
5 class template<class_name>
Question No. 5 Marks : 2
A friend function of a class has access
1 To all data member and functions of the class
2 Only to other friend functions of the class
3 Only to private data of the class
4 Only to public data of the class
5 To private data declared in main()
Question No. 6 Marks : 5
Briefly describe the role of each of the following within a class:
Question No. 7 Marks : 20
Create a class named Order. This class has the following attributes/ data members
a) Create the object of this class using parameterized constructor in order to initialize OrderID and Items data members. Default values of both the data members must be equal to 1.
b) Write the following member functions of this class;
i) OrderBill ( ), this function will calculate the invoice of an order and display the result. The formula to calculate the invoice is
ii) SumPrices( ), this function will sum the prices of the items entered by the user from
keyboard in PricesOfItems array and returns the result.
c) Write the setter functions for OrderID, Items, and PricesOfItems. And getter functions for OrderID and Items.
Also write the main () to create the object of class Order.
Question No. 8 Marks : 2
The new operator
1 is used to declare objects or variables
2 can not create and initialize an object
3 names an object or variable
4 returns an address to an object or variable
5 can allocate an appropriate amount of memory for an object or variable
Question No. 9 Marks : 15
Write a program that inputs one string of max length of 10. If the string is identical to “Virtual”, output the message “Correct Password”; otherwise, output the first four characters in the message and the length of the message.
Question No. 10 Marks : 2
If we open a file stream myfile for reading, what will give us the current position of the file pointer?
Question No. 11 Marks : 2
There is a class Student, Which one of the following is a valid destructor for this class.
3 ~ Student();
4 int~ Student();
5 ~ Student(int);
Question No. 12 Marks : 5
What is a friend function? Explain with example?
Question No. 13 Marks : 6
Write code that will declare, initialize, and fill in an array of objects of type int. After your code executes, the array should look as follows.
0 2 4 6 8 10 12 14 16 18
CS408-Human Computer Interaction
Draw a diagram to illustrate the model for different types of memory. Provide a brief explanation.
Describe the design principles given below with some examples and explain their implications for interface design.
? Visibility ? Affordance
Define usability and user experience. Draw a conceptual diagram that illustrates the relationship between an interface, usability, user experience and the interaction between humans and computers. Provide a brief explanation of this diagram with examples.
Describe Norman’s interaction framework with reference to the action and evaluation cycle. What is the gulf of evaluation and gulf of execution? Your answer must also be illustrated with a diagram.
What is the gulf of evaluation and gulf of execution? Define HumanComputer Interaction.