Recent questions tagged parameter-passing

0 0 votes
0 0 answers
146
146 views
Which of the following is an example of passing a parameter by reference in $\text{C}?$ void func(int $\text{x}$)void func(int & $\text{x}$)void func(int $\text{x},$ int ...
4 4 votes
1 1 answer
1.3k
1.3k views
#include<stdio.h int test(int *a, int *b) { int c = *a-*b; if (c<0) return 0; else return (1 + test(&c, b)); } void main() { int x = 15; int y = 4; int a = test(&x,&y); p...
1 1 vote
2 2 answers
1.0k
1.0k views
What is printed by the print statements in the program $\text{P1}$ assuming call by reference parameter passing ?Program P1() { x = 10; y = 3; func1(y, x, x); print x; pr...
1 1 vote
1 1 answer
987
987 views
int x = 5, y = 10 ; void main ( ) { int i = 2, j = 3 A (i, j); } void A (int i, int j) { int x = 10, y = 5 ; i = i + x : j = i + y : printf ("%d %d", i, j); B (i, j); } v...
0 0 votes
1 1 answer
1.4k
1.4k views
#include<stdio.h>int fun(int arr[]){ arr=arr+1; printf("%d",arr[0]);}int main(void){ int arr ={10,20}; fun(arr); printf("%d",arr[0]); return 0;}A.COMPIL...
0 0 votes
1 1 answer
2.2k
2.2k views
Consider the following two $C++$ programs $P1$ and $P2$ and two statements $S1$ and $S2$ about these programs:$P1$$P2$void f(int a, int *b, int &c){a=1;*b=2;c=3;}int main...
6 6 votes
2 answers 2 answers
2.7k
2.7k views
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 p...
0 0 votes
1 1 answer
1.8k
1.8k views
Predict the Output for both the snippets for the following:1. Call by Value2. Call by Reference3. Call by Need4. Call by Name5. Call by value Result/Call by value Return(...
0 0 votes
0 0 answers
911
911 views
from below list of parameter passing techniques, which parameter passing technique we can implement in c?1) call by value2) call by refference3) call by value result4) ca...
0 0 votes
0 0 answers
593
593 views
why we use parameter passing technique in C??ORpurpose of using "parameter passing technique"??ORwhat is the advantage of using it in C??
0 0 votes
0 0 answers
822
822 views
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 ?
0 0 votes
0 0 answers
940
940 views
Does C support all passing parameters techniques like call by text, call by copy restore, and call by name?
78 78 votes
7 answers 7 answers
26.5k
26.5k views
#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;...
1 1 vote
1 answers 1 answer
1.6k
1.6k views
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$ i...
6 6 votes
1 answers 1 answer
1.2k
1.2k views
Consider the following code snippet.void first(int p, int t) { p += t; t += p; } main() { int p = 4; first(p , p); }What is the final value of $p$ in both call by value a...
0 0 votes
0 0 answers
1.1k
1.1k views
foo(a, b, c) { b =b++; a = a++; c = a + b*10 } X=1; Y=2; Z=3; foo(X, Y+2, Z);CAN SOMEONE PLEASE TELL THE OUTPUTS FOR CALL BY REFERENCE AND CALL BY NAME. WHAT IS THE DIFER...
9 9 votes
2 answers 2 answers
4.0k
4.0k views
Consider the following program fragment :int foo(int ,int ); int a; int ar[4] = { 1,0, 2,3}; main() { a = 0; foo(ar[a], ar[ar[a]]); printf("%d,%d ,%d,%d ", ar[0] , ar ,a...
8 8 votes
1 1 answer
3.4k
3.4k views
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 ...
23 23 votes
1 answers 1 answer
4.0k
4.0k views
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, o...
6 6 votes
2 answers 2 answers
3.4k
3.4k views
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); ...
0 0 votes
2 2 answers
1.3k
1.3k views
The default parameter passing mechanism of functions is A) Call by ValueB) Call by ReferenceC) Call by ResultD) None of the above
7 7 votes
3 answers 3 answers
1.8k
1.8k views
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 co...
3 3 votes
1 1 answer
2.5k
2.5k views
Assume that the program $‘P’$ is implementing parameter passing with ‘call by reference’. What will be printed by following print statements in $P$?Program P { x=10; y=3;...