Log In

Recent questions tagged parameter-passing

0 votes
1 answer
#include<stdio.h> int fun(int arr[]) { arr=arr+1; printf("%d",arr[0]); } int main(void){ int arr[2]={10,20}; fun(arr); printf("%d",arr[0]); return 0; } A.COMPILE ERROR B.20,10 C.10,20 D.20,20
asked Jan 7, 2019 in Programming Arun Rout 117 views
3 votes
2 answers
Consider the following program fragment: var a,b : integer; procedure G(c,d: integer); begin c:=c-d; d:=c+d; c:=d-c end; a:=2; b:=3; G(a,b); If both parameters to $G$ are passed by reference, what are the values of $a$ and $b$ at the end of the above program fragment ? $a=0$ and $b=2$ $a=3$ and $b=2$ $a=2$ and $b=3$ $a=1$ and $b=5$ None of the above
asked Dec 18, 2018 in Programming Arjun 454 views
0 votes
1 answer
Predict the Output for both the snippets for the following: 1. Call by Value 2. Call by Reference 3. Call by Need 4. Call by Name 5. Call by value Result/Call by value Return(Copy Restore) 6. Call by Text
asked Nov 15, 2018 in Programming Balaji Jegan 239 views
0 votes
0 answers
from below list of parameter passing techniques, which parameter passing technique we can implement in c? 1) call by value 2) call by refference 3) call by value result 4) call by name 5) call by text 6) call by need
asked Oct 3, 2018 in Programming Rahul_Rathod_ 114 views
0 votes
0 answers
why we use parameter passing technique in C?? OR purpose of using "parameter passing technique"?? OR what is the advantage of using it in C??
asked Sep 13, 2018 in Programming Hira Thakur 83 views
0 votes
0 answers
What is the output.My doubt is : What is meant by call by copy restore ? is it same as call by reference or there is some difference ?
asked May 2, 2018 in Programming Na462 110 views
26 votes
4 answers
#include<stdio.h> void fun1(char* s1, char* s2){ char* temp; temp = s1; s1 = s2; s2 = temp; } void fun2(char** s1, char** s2){ char* temp; temp = *s1; *s1 = *s2; *s2 = temp; } int main(){ char *str1="Hi", *str2 = "Bye"; fun1(str1, str2); printf("%s %s", str1, ... 0; } The output of the program above is: $\text{Hi Bye Bye Hi}$ $\text{Hi Bye Hi Bye}$ $\text{Bye Hi Hi Bye}$ $\text{Bye Hi Bye Hi}$
asked Feb 14, 2018 in Programming gatecse 6k views
1 vote
1 answer
int f(int &x, int c) { c = c-1; if (c == 0) return 1; x = x +1; return f(x,c) * x; } What is the return value of $f(p,p),$ if the value of $p$ is initialized to $4$ before the call$?$ Note that the first parameter is passed by reference, whereas the second parameter is passed by value.
asked Aug 21, 2017 in Programming Ahwan 211 views
0 votes
0 answers
asked Jan 18, 2017 in Compiler Design sushmita 376 views
2 votes
1 answer
Consider the procedure declaration: Procedure P (k: integer) where the parameter passing mechanism is call-by-value-result. Is it correct if the call, P (A[i]), where A is an array and i an integer, is implemented as below. create a new local variable, say z; assign to ... the body of P using z for k; set A [i] to z; Explain your answer. If this is incorrect implementation, suggest a correct one.
asked Dec 19, 2016 in Compiler Design jothee 460 views
16 votes
1 answer
What is printed by following program, assuming call-by reference method of passing parameters for all variables in the parameter list of procedure P? program Main(inout, output); var a, b:integer; procedure P(x, y, z:integer); begin y:=y+1 z:=x+x end P; begin a:=2; b:=3; p(a+b, a, a); Write(a) end.
asked Dec 19, 2016 in Compiler Design jothee 835 views
0 votes
2 answers
What does the following program output? program module (input, output); var a:array [1...5] of integer; i, j: integer; procedure unknown (var b: integer, var c: integer); var i:integer; begin for i := 1 to 5 do a[i] := i; b:= 0; c := 0 for i := 1 to 5 do write (a[i]); writeln(); a[3]:=11; ... (c,b); b := 5; c := 6; end; begin i:=1; j:=3; unknown (a[i], a[j]); for i:=1 to 5 do write (a[i]); end;
asked Nov 25, 2016 in Compiler Design makhdoom ghaya 473 views
0 votes
2 answers
The default parameter passing mechanism of functions is A) Call by Value B) Call by Reference C) Call by Result D) None of the above
asked Oct 27, 2016 in Programming Sankaranarayanan P.N 212 views
5 votes
2 answers
void foo(int x) { int *p = &x; *p = x*x; } The above code is supposed to modify any input integer with its square. Which of the following statements regarding the above code is correct? The given code is wrong as C uses call by value and hence ... wrong as it is not returning any value The given code is wrong as it is illegal to access the memory of a parameter variable inside a function
asked Oct 19, 2016 in Programming Arjun 276 views
1 vote
1 answer
Program P1() { x=10, y=3; func1(y,x,x); print x; print y; } func1(x,y,z) { y=y+4; z=x+y+4; } plzz elaborate the answer explanation? thanks in advance.
asked Aug 26, 2016 in Programming neha singh 368 views
2 votes
3 answers
Consider the following statements $S1, S2$ and $S3$: $S1$: In call-by-value, anything that is passed into a function call is unchanged in the caller's scope when the function returns. $S2$: In call-by-reference, a function receives implicit reference to a variable used as argument. $S3$: In call-by ... . $S3$ and $S2$ are true. $S3$ and $S1$ are true. $S2$ and $S1$ are true. $S1, S2, S3$ are true.
asked Jul 25, 2016 in Compiler Design makhdoom ghaya 924 views
1 vote
2 answers
The Default Parameter Passing Mechanism is called as Call by Value Call by Reference Call by Address Call by Name
asked Jul 13, 2016 in Programming and DS jothee 4.5k views
16 votes
1 answer
Consider the following code fragment void foo(int x, int y) { x+=y; y+=x; } main() { int x=5.5; foo(x,x); } What is the final value of x in both call by value and call by reference, respectively? 5 and 16 5 and 12 5 and 20 12 and 20
asked Jun 21, 2016 in Compiler Design jothee 3.8k views
7 votes
1 answer
In programming language terminology, $\text{ call by value }$ refers to the fact that: A function call can return a value. When a function is called, arguments are copied into local storage. Functions can indirectly modify the value of external variables. Every argument passed to a function must have a value.
asked May 19, 2016 in Compiler Design jothee 441 views
18 votes
2 answers
For the following code, indicate the output if static scope rules dynamic scope rules are used var a,b : integer; procedure P; a := 5; b := 10; end {P}; procedure Q; var a, b : integer; P; end {Q}; begin a := 1; b := 2; Q; Write ('a = ', a, 'b = ', b); end
asked Apr 24, 2016 in Compiler Design jothee 1.7k views
0 votes
1 answer
Show the activation records and the display structure just after the procedures called at lines marked $x$ and $y$ have started their execution. Be sure to indicate which of the two procedures named $A$ you are referring to. Program Test; Procedure A; Procedure B; Procedure A; begin …… end A; begin y: A; end B; begin B; end A; begin x: A; end Test
asked Apr 24, 2016 in Programming jothee 413 views
29 votes
6 answers
The following program fragment is written in a programming language that allows global variables and does not allow nested declarations of functions. global int i=100, j=5; void P(x) { int i=10; print(x+10); i=200; j=20; print (x); } main() {P(i+j);} If the ... scoping and call by name parameter passing mechanism, the values printed by the above program are $115, 220$ $25, 220$ $25, 15$ $115, 105$
asked Apr 24, 2016 in Compiler Design jothee 3.7k views
48 votes
8 answers
What will be the output of the following pseudo-code when parameters are passed by reference and dynamic scoping is assumed? a = 3; void n(x) { x = x * a; print (x); } void m(y) { a = 1 ; a = y - a; n(a); print (a); } void main () { m(a); } $6,2$ $6,6$ $4,2$ $4,4$
asked Feb 12, 2016 in Compiler Design Sandeep Singh 10.4k views
14 votes
1 answer
In which of the following case(s) is it possible to obtain different results for call-by-reference and call-by-name parameter passing? Passing an expression as a parameter Passing an array as a parameter Passing a pointer as a parameter Passing as array element as a parameter
asked Jan 22, 2016 in Compiler Design Cruise Device 1.9k views
2 votes
1 answer
P(X:integer,Y:integer) { X = 6; A = 8; return ( X + Y ) } if the function P were invoked by the following program fragment. k = 1; L = 1; Z = (K, L); Then the value of Z would be? where X=call by reference and Y=pass by value
asked Nov 16, 2015 in Programming Nishikant kumar 115 views