Programming Language Principle And Paradigm

Questions & Answers

A list of 5 unsigned numbers (1H,68H,64H,65H,0H,34,100,101,70H,4,98H) is stored starting at memory location LIST in code memory (ROM). Write a program that will: Copy the numbers from code memory (ROM) to program memory (RAM)starting at address 40H. Sum the value of the numbers then output the result on PO. Find the number of values that are greater than 1510 and output the result on P1 LEDS. 2. (5 points) Write a program that will convert a string of characters in to an all-upper-case string: The string named "MyString " defined using appropriate assembler directives and ended with 0. The original string consists of a mixture of upper- and lower-case characters in addition to spaces. - The converted string should be stored RAM starting at address 40H.


3. (2 points) Answer the following questions. If necessary, consult a reference on C (and cite your source). (a) What is the scope and what is the lifetime of a static local variable? (b) What is the scope and what is the lifetime of a static global variable?


1. public int summation (int start, int end) { 3.return start; 2. if (start == end) 4.else 5.return start + summation (start+1, end); Show the runtime stack that is built in order to calculate summa-tion(3,6). You should show the stack's state whenever an activation record is pushed on or popped off. Be sure your representation of the stack includes all dynamic links, current values for all parameters, and,when appropriate, give the return value of the function.


Consider the following C++ program, where &i means i is passed byreference: (a) What is the value of sum at the end of the function fool? Brieflyexplain why. (b) What is the value of sum at the end of the function foo2? Brieflyexplain why.


Consider the following function written in the C syntax: 1. int foo(int a, int b) { bb 10:+ 3.a = b*2; 4.return a + b; In each of the cases below, assume that the initial values of the vari-ables are x-1, y=2, and z=3. Write down the values of x, y, andz after the following calls to foo(). If necessary, assume that outputparameters are copied back to arguments in the left-to-right order. (a) z foo(x,y) where all parameters are passed by value= (b)=foo(x,y) where all parameters are passed by reference (c) Z =foo(x,y) where all parameters are passed by value-result (d)=foo(y,y) where all parameters are passed by value (e) z = foo(y,y) where all parameters are passed by reference (f) :Zfoo(y,y) where all parameters are passed by value-result


2. (3 points) Find some online material to learn C#'s namespace mecha-nism (cite your source). Explain briefly how it works and its benefits.


1. (8 points) Consider the C program given below. You will be asked to determine which variables are visible in a number of different situations. In each case, identify each variable by its name and the line number of its declaration. Note: for this problem, only list visible variable names, not function names. (a) C uses static scoping. Say which variables are visible in the bodies of each of the functions: main, A, B. (b) If C used dynamic scoping and the calling sequence is main calls B. Say which identifiers would be visible in B. (c) If C used dynamic scoping and the calling sequence is main callsA. Say which identifiers would be visible in A. (d) If C used dynamic scoping and the calling sequence is main callsA; A calls B. Say which identifiers would be visible in B.


No Search results found!

Kindly submit your queries
we will make sure available to you as soon as possible.

Search Other Question