Recent questions tagged programming

9.8k
views
2 answers
35 votes
What is the output of the following program?#include<stdio.h int funcf (int x); int funcg (int y); main () { int x = 5, y = 10, count; for (count = 1; count <= 2; ++count...
12.5k
views
3 answers
30 votes
Consider the following C program which is supposed to compute the transpose of a given $4 \times 4$ matrix $M$. Note that, there is an $X$ in the program which indicates ...
10.1k
views
3 answers
29 votes
Let $x$ be an integer which can take a value of $0$ or $1$. The statementif (x == 0) x = 1; else x = 0;is equivalent to which one of the following ?$x = 1 + x;$$x = 1 - ...
4.7k
views
2 answers
6 votes
Match the following concepts and their best possible descriptions. Concept Descriptioni.overloadinga.allows to define a class to have properties of another classii.friend...
13.3k
views
6 answers
74 votes
Which one of the choices given below would be printed when the following program is executed? #include <stdio.h int a1[] = {6, 7, 8, 18, 34, 67}; int a2[] = {23, 5...
26.1k
views
6 answers
85 votes
Which one of the choices given below would be printed when the following program is executed?#include <stdio.h void swap (int *x, int *y) { static int *temp; temp = x; x ...
27.5k
views
6 answers
101 votes
Which one of the choices given below would be printed when the following program is executed ?#include <stdio.h struct test { int i; char *c; }st[] = {5, "become", 4, "be...
5.2k
views
1 answers
7 votes
Early binding refers to a binding performed at compile time and late binding refers to a binding performed at execution time. Consider the following statements:Static sco...
7.7k
views
3 answers
15 votes
Consider the program below in a hypothetical programming language which allows global variables and a choice of static or dynamic scoping.int i; program main() { i = 10; ...
8.7k
views
1 answers
25 votes
Consider the program below in a hypothetical language which allows global variable and a choice of call by reference or call by value methods of parameter passing. ...
11.1k
views
5 answers
32 votes
Consider the C program given below : #include <stdio.h int main () { int sum = 0, maxsum = 0, i, n = 6; int a [] = {2, -2, -1, 3, 4, 2}; for (i = 0; i < n; i++) { if (i =...
13.3k
views
5 answers
49 votes
The function f is defined as follows:int f (int n) { if (n <= 1) return 1; else if (n % 2 == 0) return f(n/2); else return f(3n - 1); }Assuming that arbitrarily large int...
10.7k
views
2 answers
43 votes
C program is given below:# include <stdio.h int main () { int i, j; char a [3] = {{'a', 'b', 'c'}, {'d', 'e', 'f'}}; char b [3] ; char *p = *b; for (i = 0; i < 2; i++)...
15.2k
views
3 answers
65 votes
Consider the C program given below. What does it print?#include <stdio.h int main () { int i, j; int a [8] = {1, 2, 3, 4, 5, 6, 7, 8}; for(i = 0; i < 3; i++) { a[i] = a[i...
10.8k
views
4 answers
23 votes
Consider the C program below. What does it print?# include <stdio.h # define swapl (a, b) tmp = a; a = b; b = tmp void swap2 ( int a, int b) { int tmp; tmp = a; a = b; b ...
9.9k
views
4 answers
31 votes
What is the output printed by the following C code?# include <stdio.h int main () { char a [6] = "world"; int i, j; for (i = 0, j = 5; i < j; a [i++] = a [j ]); printf ("...
5.8k
views
2 answers
12 votes
Match the programming paradigms and languages given in the following table. Paradigms Languages(I)Imperative(a)Prolog(II)Object Oriented(b)Lisp(III)Functional(c)C, Fortra...
1.6k
views
1 answers
3 votes
Consider the following program in pseudo-Pascal syntax. What is printed by the program if parameter $a$ in procedure $\text{test1}$ is passed ascall-by-reference paramete...
5.5k
views
3 answers
21 votes
Consider the following high level programming segment. Give the contents of the memory locations for variables $W, X, Y$ and $Z$ after the execution of the program segmen...
1.9k
views
1 answers
1 votes
Consider the program below:Program main: var r:integer; procedure two: begin write (r); end procedure one: var r:integer; begin r:=5; two; end begin r:=2; two; one; two; ...
25.8k
views
3 answers
37 votes
Consider the following recursive function:function fib (n:integer);integer; begin if (n=0) or (n=1) then fib := 1 else fib := fib(n-1) + fib(n-2) end;The above function i...
4.0k
views
2 answers
22 votes
An unrestricted use of the "$goto$" statement is harmful becauseit makes it more difficult to verify programsit increases the running time of the programsit increases the...
2.2k
views
1 answers
4 votes
Consider the following program in Pseudo-Pascal syntax.program what: var z: integer procedure recur(x): begin if x <= 40 then begin x:x+z recur(x); z:=x+10 end end(*recur...
9.9k
views
3 answers
37 votes
What does the following program print?#include<stdio.h void f(int *p, int *q) { p=q; *p=2; } int i=0, j=1; int main() { f(&i, &j); printf("%d %d\n", i,j); return 0; }$2 \...
14.1k
views
4 answers
45 votes
Consider the following C code segment.int a, b, c = 0; void prtFun(void); main() { static int a = 1; /* Line 1 */ prtFun(); a += 1; prtFun(); printf(“ \n %d %d ”, a, ...
20.8k
views
2 answers
44 votes
What does the following fragment of C program print?char c[] = "GATE2011"; char *p = c; printf("%s", p + p[3] - p );$\text{GATE2011}$$\text{E2011}$$2011$$011$
9.1k
views
4 answers
41 votes
Consider the C function given below.int f(int j) { static int i = 50; int k; if (i == j) { printf("something"); k = f(i); return 0; } else return 0; }Which one of the fol...
19.7k
views
4 answers
59 votes
Consider the following function.double f(double x){ if( abs(x*x - 3) < 0.01) return x; else return f(x/2 + 1.5/x); }Give a value $q$ (to $2$ decimals) such that $f(q)$ wi...
16.0k
views
4 answers
133 votes
Suppose $n$ and $p$ are unsigned int variables in a C program. We wish to set $p$ to $^nC_3$. If $n$ is large, which one of the following statements is most likely to set...
21.3k
views
4 answers
78 votes
Consider this C code to swap two integers and these five statements: the codevoid swap (int *px, int *py) { *px = *px - *py; *py = *px + *py; *px = *py - *px; }S1...