Question
Exercise E1 Give an example of binding at each of the following binding times: language design time; b) language implementation time; c) compile time; d)
Exercise E1
- Give an example of binding at each of the following binding times:
- language design time; b) language implementation time; c) compile time; d) linkage time
e) load time; f) execution time.
B. What is the difference between static type binding and dynamic type binding?
C. in C++, what is the difference between the following two statements:
a) int num; and b) extern int num;
D. in a language that supports type inference, do you need to specify the data type of the variable l or w in the definition of each of the following functions? Explain your answer.
fun computePeri( l, w ) = 2 * (l + w); fun computeArea( l, w ) = l * w;
E. Write the simple assignment that corresponds to each of the following compound assignment:
num * = 5; result * = num + 2;
F. Assume that variables i, j, n and m are declared as follows: int i = 6 , j = 10 , n , m;
Show the value of each variable after the execution of the following instructions:
(NB: the questions are independent).
n = --i * j++; n= ______________ i=______________ j = ____________
m = i- - * ++ j; m= ______________ i=_______________ j = _____________
Exercise E2
Do the following exercises from the book: 9 page 343 & 344; 13 page 344 and 20 page 345.
Exercise E3
Assuming that the variables are defined and initialized as follows:
int num1 = 9 , num2 = 5 , num3 = 10;
float fnum = 12.50;
char ch = P;
A. Evaluate the following conditions (using short circuit evaluation whenever possible):
a) 2 * num1 - 5 >= 9 || fnum / 2 + 10 <= 6.5
b) num1 + 5 = = 24 || num1 1 > num2 - 5
c) num1 + num2 == num3 + 5 && 2 * num3 <= 4 * num2
d) 2 * num1 - 5 >= 9 && fnum / 2 + 10 <= 6.5
e) num1 - num2 <= num1 / 3 || num1 * num2 > 100
f) ! (num1 + 5 <= 13)
g) num1 - 5 >= num3 || num2 < 15 && num1 >= 9
B. Which of the following C++ conditions are equivalent (that means have the same true value)?
a) num1 != 0 d) !num1
b) num1 == 0 e) !(num1 == 0) c) num1
Exercise E4
Show the values of the variables $result1 and $result2 after the execution of the following statements:
($num1, $num2, $result1, $result2) = (24, 4, 0, 0);
$num1 > $num2 ? $result1 : $resul2 = $num1 / $num2;
($num1, $num2) = ($num2, $num1);
Exercise E5
Show the output of the following C++ program segment:
- For the input values: 25 and 3.
- For the input value 4 and 12.
int num1, num2;
cin >> num1 >> num2;
cout << 2 + (num1 > num2 ? num1/ num2 : num2 / num1);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started