Show the symbol table and activation record for the following function.
double cubic(double x, int a, int b, int c, int d)
{
double y = 0.0;
y = a*x*x*x + b*x*x + c*x + d;
return y;
}
A.
| Variable | Type | Byte(space) |
| x | double | 8 bytes |
| a | Integer | 2 bytes |
| b | Integer | 2 bytes |
| c | Integer | 2 bytes |
| d | Integer | 2 bytes |
| y | double | 8 bytes |
B. The structure of an activation record is as follows,
0xcff3: 0000 ; local variable a <= R6 (top of stack) 0xcff4: 0000 ; local variable b 0xcff5: 0004 ; local variable c 0xcff6: 0007 ; local variable d 0xcff7: 0000 ; local variable x 0xcff8: 0000 ; local variable y <== R5 0xcff9: cfff ; frame pointer of "cubic" 0xcffa: 300a ; Return address 0xcffb: 0000 ; Return value
Show the symbol table and activation record for the following function. double cubic(double x, int a,...
Consider the following method: public static int mystery (int x, double y, char ch) { int u; if ('A' <= ch && ch <= 'R') return (2 * x + (int)(y)); else return((int)(2 * y) - x); } What is the output of the following Java statements? a. System.out.println (mystery(5, 4.3, 'B')); b. System.out.println (mystery(4, 9.7, 'v')); c. System.out.println (2 * mystery(6, 3.9, 'D'));
Complete the symbol table entries for the parameters and variables in the following Jack function: function int blowupstack(int c, int z) { var string message ; var int d, a; let ca blowupstack(a,z); return z; } The symbol has four columns: Identifier, type, segment, offset. a, int, argument, 2 < c, int, [Choose ] V d, int, argument, 1 < z, int, [ Choose ] message, string, [Choose ] < this, 1 local, o this, 3 argument, 4 argument, 3...
a) Make a function which returns x/3 with a given integer x. double third(int x) { //Complete your code below. ______________________________________ return y; } b) Make a program which shows 2 ∗ n with a given user input n. #include<iostream> using namespace std; // Complete the blank. _______________________ int main(){ int n; cout<<"Enter:"; cin>>n; cout<<twice(n); return 0; } int twice(int x){ return 2*x; } c) Make a function which returns true if n is positive, otherwise returns false. ________ positive(int...
Convert this code from C to C++
include <stdio.h> include <locale.h> void filtre (double x. double yll, double yol, int , int N) int Nn-10000 int main) setlocale (LC ALL,") double x(Nm) , y [ Nm],yo Nml®(0.0); int m; FILE dosyal-fopen("D:/veri/673.txtr FILE dosya2-fopen("D:/veri/data2.txt int i-0 while( feof (dosyal)) fscanf (dosyal, " ",xi sytil) fclose (dosyal) int Nij printf("Pencere Genişligi scanf() 3 filtre(x,y.Yo,m,N) for(int k-0keNkt+)fprintf (dosya2, 10.41 10.411 0.41fn",x[k],y[k].yo[k]) fclose(dosya2) void filtre (double x double y. double yoll, int m, int...
Write a program that contains a main function, a “double custom_operator_function(int op_type, double x, double y)”, a “double min(double,double)”, a double max(double x,double y), and a double pow(double x, int y). The main function is used to call the custom operator function. Next, the custom operator function calls the min/max/pow functions based on the op_type. From the main, call the custom operator function with the three inputs 1/-3/5, 2/4/5, and 3/4/5. Print the result of each input to screen. i)...
White a function that swaps values using templates int main ( ) { int X=5 int Y=29 ; double a = 1.0 ; double b = 3.14 ; swap ( X , Y ) ; swap ( a , b ) ; return 0 ; } I need you to explain it step by step
Assignment: Show the symbol table for the following C programs at the printf lines (a) using lexical scope and (b) using dynamic scope. What does the program print using each kind of scope rule? Program 1: const int b = 10; int foo() { int a = b + 10; return a; } int bar() { int b = 4; return foo(); } int main() { printf(“foo = %d\n”,foo()); printf(“bar = %d\n”,bar()); return 0; } Program 2: int a; void...
QUESTION 62 Consider the following code: void Pancake(int x, int& y, int z); void Waffle(int& x, int& y); int Doughnut(int y, int z); int main( ) { int a = 1; int b = 2; int c = 3; int d = 4; Pancake(a, b, c); Waffle(b, c); Pancake(d, c, b); d = Doughnut(b, a); return 0; } void Pancake(int x, int& y, int z) { y += 3; ...
(5.00 Points) 11 - The function prototype double mySqrt(int x); defines a function called a) double which calculates square roots b) mySqrt which takes an integer as an argument and returns a double c) mysqrt which takes an argument of type x and returns a double d) mysqrt which takes a double as an argument and returns an integer
What is the selection that best describes the following statement: int function( int, double [ ] ); A) function prototype B) function call C) function definition D) none of the above