Recent questions tagged programming

6.9k
views
2 answers
15 votes
Consider the following code written in a pass-by-reference language like FORTRAN and these statements about the code. subroutine swap(ix,iy) it = ix L1 : ix = iy L2 : iy ...
17.8k
views
5 answers
62 votes
Consider the following program in C language:#include <stdio.h main() { int i; int*pi = &i; scanf("%d",pi); printf("%d\n", i+5); }Which one of the following statements is...
9.0k
views
1 answers
28 votes
Faster access to non-local variables is achieved using an array of pointers to activation records called a stackheapdisplayactivation tree
7.3k
views
3 answers
25 votes
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.9k
views
2 answers
6 votes
Consider the following program in a language that has dynamic scooping:var x: real; procedure show: begin print(x);end; procedure small; var x: real; begin x: = 0.125; sh...
12.8k
views
5 answers
31 votes
Given the programming constructsassignmentfor loops where the loop parameter cannot be changed within the loopif-then-elseforward go toarbitrary go tonon-recursive proced...
16.7k
views
8 answers
51 votes
Consider the following C program:double foo (double); /* Line 1 */ int main() { double da, db; //input da db = foo(da); } double foo (double a) { return a; }The above cod...
6.0k
views
4 answers
11 votes
Which one of the following are essential features of an object-oriented programming language?Abstraction and encapsulationStrictly-typednessType-safe property coupled wit...
12.5k
views
3 answers
13 votes
A common property of logic programming languages and functional languages is:both are procedural languages both are based on $\lambda$-calculusboth are declarativeboth us...
21.0k
views
5 answers
39 votes
What does the following C-statement declare?int (*f) (int * );A function that takes an integer pointer as argument and returns an integerA function that takes an integer ...
10.6k
views
1 answers
26 votes
Consider the following C function:int f(int n) { static int r = 0; if (n <= 0) return 1; if (n 3) { r = n; return f(n-2) + 2; } return f(n-1) + r; }What is the value of ...
7.2k
views
5 answers
26 votes
Choose the best matching between the programming styles in Group 1 and their characteristics in Group 2.$$\begin{array}{|ll|ll|}\hline \rlap{\textbf{Group 1}} & & \rlap{...
13.3k
views
2 answers
34 votes
Consider the following C program segment:char p[20]; int i; char* s = "string"; int length = strlen(s); for(i = 0; i < length; i++) p[i] = s[length-i]; printf("%s", p);Th...
12.5k
views
5 answers
32 votes
Consider the following program fragment for reversing the digits in a given integer to obtain a new integer.Let $n = d_1\, d_2\, \ldots\, d_m$.int n, rev; rev = 0; while(...
14.9k
views
3 answers
28 votes
Consider the following C function:int f(int n) { static int i = 1; if(n >= 5) return n; n = n+i; i++; return f(n); }The value returned by $f(1)$ is:$5$$6$$7$$8$
9.2k
views
2 answers
24 votes
The goal of structured programming is to:have well indented programsbe able to infer the flow of control from the compiled codebe able to infer the flow of control from t...
12.8k
views
5 answers
40 votes
Consider the C program shown below:#include<stdio.h #define print(x) printf("%d", x) int x; void Q(int z) { z+=x; print(z); } void P(int *y) { int x = *y + 2; Q(x); *y = ...
5.6k
views
2 answers
2 votes
Consider the following class definitions in a hypothetical Object Oriented language that supports inheritance and uses dynamic binding. The language should not be assumed...
3.9k
views
0 answers
5 votes
Consider the following logic program P$\begin{align*} A(x) &\gets B(x,y), C(y) \\ &\gets B(x,x) \end{align*}$Which of the following first order sentences is equivalent to...
9.3k
views
4 answers
39 votes
Which of the following statements is FALSE?In statically typed languages, each variable in a program has a fixed typeIn un-typed languages, values do not have any typesIn...
30.7k
views
4 answers
72 votes
Assume the following C variable declaration:int *A[10], B[10][10];Of the following expressions:$A $$A [3]$$B $$B [3]$which will not give compile-time errors if used as le...
3.4k
views
2 answers
24 votes
The following recursive function in C is a solution to the Towers of Hanoi problem.void move(int n, char A, char B, char C) { if (......................) { move (...........
10.5k
views
3 answers
35 votes
The C language is:A context free languageA context sensitive languageA regular languageParsable fully only by a Turing machine
28.4k
views
4 answers
39 votes
Consider the following declaration of a two-dimensional array in C:char $a[100][100]$;Assuming that the main memory is byte-addressable and that the array is stored start...
8.5k
views
2 answers
13 votes
The results returned by function under value-result and reference parameter passing conventionsDo not differDiffer in the presence of loopsDiffer in all casesMay differ i...
10.4k
views
1 answers
41 votes
In the C language:At most one activation record exists between the current activation record and the activation record for the mainThe number of activation records betwee...
11.3k
views
2 answers
31 votes
Consider the following C program:void abc(char*s) { if(s[0]=='\0')return; abc(s+1); abc(s+1); printf("%c",s[0]); } main() { abc("123"); }What will be the output of the pr...
7.5k
views
2 answers
11 votes
Consider the following programProgram P2 var n : int; procedure W(var x : int) begin x = x + 1; print x; end procedure D begin var n : int; n = 3; W(n); end begin \\begin...
24.8k
views
3 answers
62 votes
Consider the following three C functions:$[P1]$ int *g(void) { int x = 10; return (&x); }$[P2]$ int *g(void) { int *px; *px = 10; return px; }$[P3]$ int *g(void) { int *p...
3.1k
views
2 answers
6 votes
Consider the following program is pseudo-Pascal syntaxprogram main; var x: integer; procedure Q (z: integer); begin z := z+x; writeln(z); end; procedure P (y: integer);...