CS508 Final term Paper 2005

CS508 Final Term Paper 2005 of Modern Programming Languages

SEMESTER FALL 2005

Total Marks =M =  100 
Duration: 3 Days 

CS508 - Modern Programming Languages - Q. No. 1                                M - 25

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);
}

void main()
{
double w;
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.

CS508 - Modern Programming Languages - Q. No. 2                                   M -15

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.

CS508 - Modern Programming Languages - Q. No. 3                                      M - 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.

CS508 - Modern Programming Languages - Q. No. 4                                        M - 15

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++.


CS508 - Modern Programming Languages - Q. No. 5                                        M - 25

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:

(i)         C++
(ii)        Java
(iii)       Javascript
(iv)       PHP
(v)        C#

Leave a Reply

Related Posts Plugin for WordPress, Blogger...