0% found this document useful (0 votes)
14 views

Programming Languages Assignment 2: Deadline: Sunday 14 Feb 2021

This document outlines an assignment for a programming languages course. It contains two programming problems worth 15 marks each (CLO 1 and CLO 2). Problem 1 involves answering short questions about language design topics like coercion, referential transparency, and enumeration types. Problem 2 involves writing Prolog and Common Lisp code to implement sorting and recursion, as well as analyzing a C function call evaluation order problem. The assignment is due on February 14, 2021 and must be submitted in .docx or .pdf format to avoid plagiarism penalties.

Uploaded by

ali sheikh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Programming Languages Assignment 2: Deadline: Sunday 14 Feb 2021

This document outlines an assignment for a programming languages course. It contains two programming problems worth 15 marks each (CLO 1 and CLO 2). Problem 1 involves answering short questions about language design topics like coercion, referential transparency, and enumeration types. Problem 2 involves writing Prolog and Common Lisp code to implement sorting and recursion, as well as analyzing a C function call evaluation order problem. The assignment is due on February 14, 2021 and must be submitted in .docx or .pdf format to avoid plagiarism penalties.

Uploaded by

ali sheikh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Programming Languages

Assignment 2
Deadline: Sunday 14 Feb 2021
Note: You have to submit the assignment either in .docx or .pfd format. In case of plagiarism
you will be award zero.
Problem 1: Answer the following short questions. 15 Marks. [CLO 1]
1. Explain how the coercion rules of a language affect its error detection.?
2. How is referential transparency related to functional side effects?
3. Do you think the elimination of explicit type conversion in your favorite
language would be beneficial? Why or why not? Support your arguments.
4. What are the design issues for enumeration types?
5. What advantages do Java and C# reference type variables have over the
pointers in other language.

Problem 2: Answer the following question briefly. 15 Marks. [CLO 2]


1. Using the structures parent(X, Y), male(X), and female(X), write a
structure that defines mother(X, Y).
2. Write a Prolog program that implements an insertion sort.
3. Write a common lisp program to find the greatest common divisor of two
numbers.
4. Write a Prolog function to print the Fibonacci series up to the nth term.
5. Let the function fun be defined as

int fun(int*k) {
*k += 4;
return 3 * (*k) - 1;
}
Suppose fun is used in a program as follows:
void main() {
int i = 10, j = 10, sum1, sum2;
sum1 = (i / 2) + fun(&i);
sum2 = fun(&j) + (j / 2);
}

What are the values of sum1 and sum2


a. operands in the expressions are evaluated left to right?
b. operands in the expressions are evaluated right to left?

You might also like