Consider the following C, C++, or Java assignment statement:
value = value * 10;
Assume that the variable value is declared and initialized.
What are some of the bindings and their binding times for parts of the above assignment statement? Use the following bullets listing style.
*
*
*
*
*
*
Write an example of Implicit heap dynamic variable in a selected programming language:
Write an example of Stack-dynamic variable in a selected programming language:
Stack Dynamic variables
- They are usually local variables of functions including arguments.
-When the declaration are elaborated storage bindings are created.
-When the function is called, local variables are allocated on run-time stack and variable is bound to address.
-When the function returns all the space is deallocated.
-The allocation and deallocation is done at runtime i.e., dynamically.
eg:
#include <iostream>
using namespace std;
sum(int num1, int num2)
{
int num3 = num1+num2;
return num3;
}
int main(){
cout<<sum(1,99);
return 0;
}
Implicit Heap Dynamic Variables
-Allocation and deallocation is caused by assignment statements.
-variables are bound to heap storage only when they are assigned values.
-Mainly used in scripting languages.
-All strings and arrays in Perl,PHP,JavaScript and; Lists in LISP and Scheme are examples.
eg:List in LISP
o/p =>(1 2 3 4 5)
o/p =>(1 2)
Consider the following C, C++, or Java assignment statement: value = value * 10; Assume that...
1) Given the following ‘generic’ program. var aVar; aVar = 10; sub1(); function sub1 () { Sub2(); Print (“ aVar = “ aVar + “\n”); } function sub2() { var aVar; aVar = 4; } What would be output under static-scoping rules? What would be output under dynamic-scoping rules? 2) Discuss and compare the following memory allocation strategies for variables, give an example of how Java and/or Python uses each: Stack-Dynamic Explicit Heap-Dynamic Implicit Heap-Dynamic 3) What is a descriptor?...
The objectives of this assignment are to: Further enhance your knowledge and skill in Java. Gain an understanding and experience with stacks. Gain further experience using generics. Continue to practice good programming techniques. Create a stack class named MyStack that stores generics with the methods shown below. Write a test program that thoroughly tests your stack implementation. void push(E item) push item onto top of stack E peek() return item on top of stack E pop() return item on top...
In the Pascal programming language, the If-Statement is defined as follows: Consider the following statement, and then answer the related questions: <If-Statement> ::= If <Condition> Then <Statement> [Else<Statement>] <Statement> ::= <If-Statement> | <While-Statement> | <For-Statement> | <Assignment-Statement> <Condition> ::= [not] <Condition> | [not] <BooleanVariable> | <Variable> <Operator> Variable> | <Variable> <Operator> <Expression> | < Expression > <Operator> <Variable> | < Expression > <Operator> < Expression> | < Expression > <Operator> < Literal > | <Variable> <Operator> < Literal > <Operator>...
Question 4 (1 point) Consider the following piece of C code. What can be said about the pop() function in this piece of code only? struct node { struct node *next; void *value; }; static struct node *stack; void * pop() { void * value = stack->value; void * pop() { void * value = stack->value; free (stack); stack = stack->next; return value; } void push (void *value) { struct node *node = malloc(sizeof(struct node)); node->value = value; node->next =...
NEED ASAP PLEASE WILL GIVE GOOD RATE RIGHT AWAY FOR ALL
ANSWERS!
MULTIPLE CHOICE
no explanation needed
SPRING Cs 424-524 aUESTION 1 12 points each, 30 points total +2 extra) Multiple 1. The main reason to include enumeration types in a programming language is to TEST2 choice: circle or check the best answer a. Make programs run faster b. Improve program readability c. Eliminate unnecessary /O d. Reduce type errors 2. A C++ value parameter is an example of a....
Write an assignment statement that performs the following operation with variables a, b, and c. Assume the variables have already been declared with the proper type. Do not use any spaces in your answer. Stores the character for the letter K in c
1. Consider the following questions a) Is it True or False that “Call by value” in a C function (C programming language) always return a value? b) Based on the following: x := 10; y := 5; z := x + y; write(z); Execution of these statements prints the value 42 on the console. Is this language Declarative or Imperative? c) Which language processing component detects the following Java error? int x, y; boolean z; z = x + y...
Stacks and Java 1. Using Java design and implement a stack on an array. Implement the following operations: push, pop, top, size, isEmpty. Make sure that your program checks whether the stack is full in the push operation, and whether the stack is empty in the pop operation. None of the built-in classes/methods/functions of Java can be used and must be user implemented. Practical application 1: Arithmetic operations. (a) Design an algorithm that takes a string, which represents an arithmetic...
Programming classes (C, C++, Matlab, Java), regardless of language, often revolve around syntax. However, the underlying algorithm and the planning that goes into it is often the more critical part of computer programming This assignment will walk you through the steps of basic algorithm development. our job is to write a flowchart and pseudocode for the task below. You can follow the example given in the appendix as a guide. We have an array of size 10 . The entries...
Java Programming: Make a Java program with two processes, a producer and a consumer. If you want to use another language, clear it with me first. The producer process consists of a loop that writes the loop count (a value from 0 to 4) into a variable that it shares with the consumer process (this variable is to be initialized to 100). On each pass through the loop, before the producer writes into the shared variable, it does a random...