What is the result of the following program? program side-effect (input, output); var x, result: integer; function f (var x:integer:integer; begin x:x+1;f:=x; end begin x:=5; result:=f(x)*f(x); writeln(result); end
GATE CSE · Programming In C
Practice problems for Function in Programming in C.
114 questions · 14 PYQs · 0 AI practice · GATE CSE 2027
What is the result of the following program? program side-effect (input, output); var x, result: integer; function f (var x:integer:integer; begin x:x+1;f:=x; end begin x:=5; result:=f(x)*f(x); writeln(result); end
Which of the following macros can put a macro assembler into an infinite loop? I. .MACRO M1, X .IF EQ, X ;if X=0 then M1 X + 1 .ENDC .IF NE, X ;if X [latex]\neq[/latex] O then .WORD X ;address (X) is stored here .ENDC .ENDM II. .MACRO M2, X .IF EQ, X M2 X .ENDC .IF NE, X .WORD X + 1 .ENDC .ENDM
What are x and y in the following macro definition? macro Add x, y Load y Mul x Store y end macro
A language with string manipulation facilities uses the following operations head(s): first character of a string tail(s): all but exclude the first character of a string concat(s1, s2): s1s2 For the string "acbc" what will be the output of concat(head(s), head(tail(tail(s))))
What is the value of X printed by the following program? program COMPUTE (input, output); var X:integer; procedure FIND (X:real); begin X:=sqrt(X); end; begin X:=2 FIND(X); writeln(X); end.
In which of the following cases is it possible to obtain different results for call-by-reference and call-by-name parameter passing methods?
Refer to the PASCAL program shown below. Program PARAM (input, output); var m, n : integer; procedure P (var, x, y : integer); var m : integer; begin m : = 1; x : = y + 1 end; procedure Q (x:integer; vary : integer); begin x:=y+1; end; begin m:=0; P(m,m); write (m); n:=0; Q(n*1,n); write (n) end What is the scope of m declared in the main program?
Refer to the PASCAL program shown below. Program PARAM (input, output); var m, n : integer; procedure P (var, x, y : integer); var m : integer; begin m : = 1; x : = y + 1 end; procedure Q (x:integer; vary : integer); begin x:=y+1; end; begin m:=0; P(m,m); write (m); n:=0; Q(n*1,n); write (n) end The value of m, output by the program PARAM is:
Refer to the PASCAL program shown below. Program PARAM (input, output); var m, n : integer; procedure P (var, x, y : integer); var m : integer; begin m : = 1; x : = y + 1 end; procedure Q (x:integer; vary : integer); begin x:=y+1; end; begin m:=0; P(m,m); write (m); n:=0; Q(n*1,n); write (n) end The value of n, output by the program PARAM is:
What type of parameter passing mechanism (call-by-value, call-by-reference, call-by-name, or-by-value result) is the following sequence of actions trying to implement for a procedure call P(A[i]) where P (i:integer) is a procedure and A is an integer array? Is the implementation correct? Explain and correct it if necessary. You are supposed to make only small changes Create a new local variable, say z. Assign to z the value of A[i]. Execute the body of P using z for A[i] Set A[i] to z.?
Choose the correct alternatives (more than one may be correct) and write the corresponding letters only: Consider the following Pascal function: Function X(M:integer):integer; Var i:integer; Begin i := 0; while i*i < M do i:= i+1 X := i end The function call X(N), if N is positive, will return
In which of the following case(s) is it possible to obtain different results for call-by-reference and call-by-name parameter passing?
For the program given below what will be printed by the write statements marked (1) and (2) in the program if the variables are dynamically scoped? Var x, y:interger; procedure P(n:interger); begin x := (n+2)/(n-3); end; procedure Q Var x, y:interger; begin x:=3; y:=4; P(y); Write(x); __(1) end; begin x:=7; y:=8; Q; Write(x); __(2) end.
Study the following program written in a block-structured language: Var x, y:interger; procedure P(n:interger); begin x:=(n+2)/(n-3); end; procedure Q Var x, y:interger; begin x:=3; y:=4; P(y); Write(x) __(1) end; begin x:=7; y:=8; Q; Write(x); __(2) end. What will be printed by the write statements marked (1) and (2) in the program if the variables are statically scoped?
Want unlimited AI-generated Function questions?
Sign up free and practice with adaptive difficulty — Easy, Medium, Hard. New questions every session.
Start practising for free →